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