home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Games / larn12s.arc / LARN.ARC / BILL.C next >
C/C++ Source or Header  |  1987-10-28  |  7KB  |  200 lines

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