386BSD 0.1 development
[unix-history] / usr / othersrc / games / larn / bill.c
CommitLineData
12458000
WJ
1#include "header.h"
2/* bill.c "Larn is copyrighted 1986 by Noah Morgan. */
3static char mail600[32];
4/*
5 * function to create the tax bill for the user
6 */
7static int pid;
8static letter1()
9 {
10 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
11 if (lcreat(mail600) < 0) { write(1,"can't write 600 letter\n",23); return(0);}
12 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
13 standout("From:"); lprcat(" the LRS (Larn Revenue Service)\n");
14 standout("\nSubject:"); lprcat(" undeclared income\n");
15 lprcat("\n We heard you survived the caverns of Larn. Let me be the");
16 lprcat("\nfirst to congratulate you on your success. It is quite a feat.");
17 lprcat("\nIt must also have been very profitable for you.");
18 lprcat("\n\n The Dungeon Master has informed us that you brought");
19 lprintf("\n%d gold pieces back with you from your journey. As the",(long)c[GOLD]);
20 lprcat("\ncounty of Larn is in dire need of funds, we have spared no time");
21 lprintf("\nin preparing your tax bill. You owe %d gold pieces as",
22 (long)c[GOLD]*TAXRATE);
23 lprcat("\nof this notice, and is due within 5 days. Failure to pay will");
24 lprcat("\nmean penalties. Once again, congratulations, We look forward");
25 lprcat("\nto your future successful expeditions.\n");
26 lwclose(); return(1);
27 }
28
29static letter2()
30 {
31 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
32 if (lcreat(mail600) < 0) { write(1,"can't write 601 letter\n",23); return(0);}
33 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
34 standout("From:"); lprcat(" His Majesty King Wilfred of Larndom\n");
35 standout("\nSubject:"); lprcat(" a noble deed\n");
36 lprcat("\n I have heard of your magnificent feat, and I, King Wilfred,");
37 lprcat("\nforthwith declare today to be a national holiday. Furthermore,");
38 lprcat("\nhence three days, Ye be invited to the castle to receive the");
39 lprcat("\nhonour of Knight of the realm. Upon thy name shall it be written. . .");
40 lprcat("\nBravery and courage be yours.");
41 lprcat("\nMay you live in happiness forevermore . . .\n");
42 lwclose(); return(1);
43 }
44
45static letter3()
46 {
47 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
48 if (lcreat(mail600) < 0) { write(1,"can't write 602 letter\n",23); return(0);}
49 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
50 standout("From:"); lprcat(" Count Endelford\n");
51 standout("\nSubject:"); lprcat(" You Bastard!\n");
52 lprcat("\n I heard (from sources) of your journey. Congratulations!");
53 lprcat("\nYou Bastard! With several attempts I have yet to endure the");
54 lprcat(" caves,\nand you, a nobody, makes the journey! From this time");
55 lprcat(" onward, bewarned\nupon our meeting you shall pay the price!\n");
56 lwclose(); return(1);
57 }
58
59static letter4()
60 {
61 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
62 if (lcreat(mail600) < 0) { write(1,"can't write 603 letter\n",23); return(0);}
63 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
64 standout("From:"); lprcat(" Mainair, Duke of Larnty\n");
65 standout("\nSubject:"); lprcat(" High Praise\n");
66 lprcat("\n With a certainty a hero I declare to be amongst us! A nod of");
67 lprcat("\nfavour I send to thee. Me thinks Count Endelford this day of");
68 lprcat("\nright breath'eth fire as of dragon of whom ye are slayer. I");
69 lprcat("\nyearn to behold his anger and jealously. Should ye choose to");
70 lprcat("\nunleash some of thy wealth upon those who be unfortunate, I,");
71 lprcat("\nDuke Mainair, Shall equal thy gift also.\n");
72 lwclose(); return(1);
73 }
74
75static letter5()
76 {
77 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
78 if (lcreat(mail600) < 0) { write(1,"can't write 604 letter\n",23); return(0);}
79 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
80 standout("From:"); lprcat(" St. Mary's Children's Home\n");
81 standout("\nSubject:"); lprcat(" these poor children\n");
82 lprcat("\n News of your great conquests has spread to all of Larndom.");
83 lprcat("\nMight I have a moment of a great man's time. We here at St.");
84 lprcat("\nMary's Children's Home are very poor, and many children are");
85 lprcat("\nstarving. Disease is widespread and very often fatal without");
86 lprcat("\ngood food. Could you possibly find it in your heart to help us");
87 lprcat("\nin our plight? Whatever you could give will help much.");
88 lprcat("\n(your gift is tax deductible)\n");
89 lwclose(); return(1);
90 }
91
92static letter6()
93 {
94 sprintf(mail600,"/tmp/#%dmail600",pid); /* prepare path */
95 if (lcreat(mail600) < 0) { write(1,"can't write 605 letter\n",23); return(0);}
96 lprcat("\n\n\n\n\n\n\n\n\n\n\n\n");
97 standout("From:"); lprcat(" The National Cancer Society of Larn\n");
98 standout("\nSubject:"); lprcat(" hope\n");
99 lprcat("\nCongratulations on your successful expedition. We are sure much");
100 lprcat("\ncourage and determination were needed on your quest. There are");
101 lprcat("\nmany though, that could never hope to undertake such a journey");
102 lprcat("\ndue to an enfeebling disease -- cancer. We at the National");
103 lprcat("\nCancer Society of Larn wish to appeal to your philanthropy in");
104 lprcat("\norder to save many good people -- possibly even yourself a few");
105 lprcat("\nyears from now. Much work needs to be done in researching this");
106 lprcat("\ndreaded disease, and you can help today. Could you please see it");
107 lprcat("\nin your heart to give generously? Your continued good health");
108 lprcat("\ncan be your everlasting reward.\n");
109 lwclose(); return(1);
110 }
111
112/*
113 * function to mail the letters to the player if a winner
114 */
115static int (*pfn[])()= { letter1, letter2, letter3, letter4, letter5, letter6 };
116mailbill()
117 {
118 register int i;
119 char buf[128];
120 wait(0); pid=getpid();
121 if (fork() == 0)
122 {
123 resetscroll();
124 for (i=0; i<sizeof(pfn)/sizeof(int (*)()); i++)
125 if ((*pfn[i])())
126 {
127 sleep(20); sprintf(buf,"mail %s < %s",loginname,mail600);
128 system(buf); unlink(mail600);
129 }
130 exit();
131 }
132 }