bill.c 5.5 KB

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