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