bill.c 5.7 KB

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