home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / games / larn / store.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-13  |  21.6 KB  |  692 lines

  1. /*-
  2.  * Copyright (c) 1988 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #ifndef lint
  35. static char sccsid[] = "@(#)store.c    5.4 (Berkeley) 5/13/91";
  36. #endif /* not lint */
  37.  
  38. /*    store.c        Larn is copyrighted 1986 by Noah Morgan. */
  39. #include "header.h"
  40. static int dndcount=0,dnditm=0;
  41.  
  42. /*    this is the data for the stuff in the dnd store    */
  43. int maxitm=83;    /* number of items in the dnd inventory table    */
  44. struct _itm itm[90] = {
  45. /*cost      memory     iven name    iven arg   how
  46.   gp     pointer      iven[]    ivenarg[]  many */
  47.  
  48. { 2,        0,        OLEATHER,        0,        3    },
  49. { 10,        0,        OSTUDLEATHER,    0,        2    },
  50. { 40,        0,        ORING,            0,        2    },
  51. { 85,        0,        OCHAIN,            0,        2    },
  52. { 220,        0,        OSPLINT,        0,        1    },
  53. { 400,        0,        OPLATE,            0,        1    },
  54. { 900,        0,        OPLATEARMOR,    0,        1    },
  55. { 2600,        0,        OSSPLATE,        0,        1    },
  56. { 150,        0,        OSHIELD,        0,        1    },
  57.  
  58. /*cost      memory     iven name    iven arg   how
  59.   gp     pointer      iven[]    ivenarg[]  many */
  60.  
  61. { 2,        0,        ODAGGER,        0,        3    },
  62. { 20,        0,        OSPEAR,            0,        3    },
  63. { 80,        0,        OFLAIL,            0,        2    },
  64. { 150,        0,        OBATTLEAXE,        0,        2    },
  65. { 450,        0,        OLONGSWORD,        0,        2    },
  66. { 1000,        0,        O2SWORD,        0,        2    },
  67. { 5000,        0,        OSWORD,            0,        1    },
  68. { 16500,    0,        OLANCE,            0,        1    },
  69. { 6000,        0,     OSWORDofSLASHING,    0,        0    },
  70. { 10000,    0,        OHAMMER,        0,        0    },
  71.  
  72. /*cost      memory     iven name    iven arg   how
  73.   gp     pointer      iven[]    ivenarg[]  many */
  74.  
  75. { 150,        0,        OPROTRING,        1,        1    },
  76. { 85,        0,        OSTRRING,        1,        1    },
  77. { 120,        0,        ODEXRING,        1,        1    },
  78. { 120,        0,        OCLEVERRING,    1,        1    },
  79. { 180,        0,        OENERGYRING,    0,        1    },
  80. { 125,        0,        ODAMRING,        0,        1    },
  81. { 220,        0,        OREGENRING,        0,        1    },
  82. { 1000,        0,        ORINGOFEXTRA,    0,        1    },
  83.  
  84. { 280,        0,        OBELT,            0,        1    },
  85.  
  86. { 400,        0,        OAMULET,        0,        1    },
  87.  
  88. { 6500,        0,        OORBOFDRAGON,    0,        0    },
  89. { 5500,        0,        OSPIRITSCARAB,    0,        0    },
  90. { 5000,        0,        OCUBEofUNDEAD,    0,        0    },
  91. { 6000,        0,        ONOTHEFT,        0,        0    },
  92.  
  93. { 590,        0,        OCHEST,            6,        1    },
  94. { 200,        0,        OBOOK,            8,        1    },
  95. { 10,        0,        OCOOKIE,        0,        3    },
  96.  
  97. /*cost      memory     iven name    iven arg   how
  98.   gp     pointer      iven[]    ivenarg[]  many */
  99.  
  100. {    20,        potionname,    OPOTION,    0,        6    },
  101. {    90,        potionname,    OPOTION,    1,        5    },
  102. {    520,    potionname,    OPOTION,    2,        1    },
  103. {     100,    potionname,    OPOTION,    3,        2    },
  104. {    50,        potionname,    OPOTION,    4,        2    },
  105. {    150,    potionname,    OPOTION,    5,        2    },
  106. {    70,        potionname,    OPOTION,    6,        1    },
  107. {    30,        potionname,    OPOTION,    7,        7    },
  108. {    200,    potionname,    OPOTION,    8,        1    },
  109. {    50,        potionname,    OPOTION,    9,        1    },
  110. {    80,        potionname,    OPOTION,    10,        1    },
  111.  
  112. /*cost      memory     iven name    iven arg   how
  113.   gp     pointer      iven[]    ivenarg[]  many */
  114.  
  115. {    30,        potionname,    OPOTION,    11,        3    },
  116. {    20,        potionname,    OPOTION,    12,        5    },
  117. {    40,        potionname,    OPOTION,    13,        3    },
  118. {    35,        potionname,    OPOTION,    14,        2    },
  119. {    520,    potionname,    OPOTION,    15,        1    },
  120. {    90,        potionname,    OPOTION,    16,        2    },
  121. {    200,    potionname,    OPOTION,    17,        2    },
  122. {    220,    potionname,    OPOTION,    18,        4    },
  123. {    80,        potionname,    OPOTION,    19,        6    },
  124. {    370,    potionname,    OPOTION,    20,        3    },
  125. {    50,        potionname,    OPOTION,    22,        1    },
  126. {    150,    potionname,    OPOTION,    23,        3    },
  127.  
  128. /*cost      memory     iven name    iven arg   how
  129.   gp     pointer      iven[]    ivenarg[]  many */
  130.  
  131. { 100,    scrollname,        OSCROLL,    0,        2    },
  132. { 125,    scrollname,        OSCROLL,    1,        2    },
  133. { 60,    scrollname,        OSCROLL,    2,        4    },
  134. { 10,    scrollname,        OSCROLL,    3,        4    },
  135. { 100,    scrollname,        OSCROLL,    4,        3    },
  136. { 200,    scrollname,        OSCROLL,    5,        2    },
  137. { 110,    scrollname,        OSCROLL,    6,        1    },
  138. { 500,    scrollname,        OSCROLL,    7,        2    },
  139. { 200,    scrollname,        OSCROLL,    8,        2    },
  140. { 250,    scrollname,        OSCROLL,    9,        4    },
  141. { 20,    scrollname,        OSCROLL,    10,        5    },
  142. { 30,    scrollname,        OSCROLL,    11,        3    },
  143.  
  144. /*cost      memory     iven name    iven arg   how
  145.   gp     pointer      iven[]    ivenarg[]  many */
  146.  
  147. { 340,    scrollname,        OSCROLL,    12,        1    },
  148. { 340,    scrollname,        OSCROLL,    13,        1    },
  149. { 300,    scrollname,        OSCROLL,    14,        2    },
  150. { 400,    scrollname,        OSCROLL,    15,        2    },
  151. { 500,    scrollname,        OSCROLL,    16,        2    },
  152. { 1000,    scrollname,        OSCROLL,    17,        1    },
  153. { 500,    scrollname,        OSCROLL,    18,        1    },
  154. { 340,    scrollname,        OSCROLL,    19,        2    },
  155. { 220,    scrollname,        OSCROLL,    20,        3    },
  156. { 3900,    scrollname,        OSCROLL,    21,        0    },
  157. { 610,    scrollname,        OSCROLL,    22,        1    },
  158. { 3000,    scrollname,        OSCROLL,    23,        0    }
  159.  };
  160.  
  161. /*
  162.     function for the dnd store
  163.  */
  164. dnd_2hed()
  165.     {
  166.     lprcat("Welcome to the Larn Thrift Shoppe.  We stock many items explorers find useful\n");
  167.     lprcat(" in their adventures.  Feel free to browse to your hearts content.\n");
  168.     lprcat("Also be advised, if you break 'em, you pay for 'em.");
  169.     }
  170.  
  171. static void dnditem();
  172.  
  173. dnd_hed()
  174.     {
  175.     register int i;
  176.     for (i=dnditm; i<26+dnditm; i++)    dnditem(i);
  177.     cursor(50,18); lprcat("You have ");
  178.     }
  179.  
  180. static void
  181. handsfull()
  182. {
  183.     lprcat("\nYou can't carry anything more!");
  184.     lflush();
  185.     nap(2200);
  186. }
  187.  
  188. static void
  189. outofstock()
  190. {
  191.     lprcat("\nSorry, but we are out of that item.");
  192.     lflush();
  193.     nap(2200);
  194. }
  195.  
  196. static void nogold()
  197. {
  198.     lprcat("\nYou don't have enough gold to pay for that!");
  199.     lflush();
  200.     nap(2200);
  201. }
  202.  
  203. dndstore()
  204.   {
  205.   register int i;
  206.   dnditm = 0;
  207.   nosignal = 1; /* disable signals */
  208.   clear();  dnd_2hed();
  209.   if (outstanding_taxes>0)
  210.     {
  211.     lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n"); beep();
  212.     lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n",(long)outstanding_taxes);
  213.     lprcat("comply with the law, we cannot serve you at this time.  Soo Sorry.\n");
  214.     cursors();    
  215.     lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
  216.     i=0;
  217.     while (i!='\33') i=getchar();
  218.     drawscreen();  nosignal = 0; /* enable signals */ return;
  219.     }
  220.  
  221.   dnd_hed();
  222.   while (1)
  223.     {
  224.     cursor(59,18); lprintf("%d gold pieces",(long)c[GOLD]);
  225.     cltoeoln(); cl_dn(1,20);    /* erase to eod */
  226.     lprcat("\nEnter your transaction ["); standout("space");
  227.     lprcat(" for more, "); standout("escape");
  228.     lprcat(" to leave]? ");
  229.     i=0;
  230.     while ((i<'a' || i>'z') && (i!=' ') && (i!='\33') && (i!=12))  i=getchar();
  231.     if (i==12) { clear();  dnd_2hed();  dnd_hed(); }
  232.     else if (i=='\33')
  233.         { drawscreen();  nosignal = 0; /* enable signals */ return; }
  234.     else if (i==' ')
  235.         {
  236.         cl_dn(1,4);
  237.         if ((dnditm += 26) >= maxitm) dnditm=0; dnd_hed();
  238.         }
  239.     else
  240.         {  /* buy something */
  241.         lprc(i);    /* echo the byte */
  242.         i += dnditm - 'a';
  243.         if (i>=maxitm) outofstock(); else
  244.         if (itm[i].qty <= 0) outofstock(); else
  245.         if (pocketfull()) handsfull(); else
  246.         if (c[GOLD] < itm[i].price*10) nogold(); else
  247.             {
  248.             if (itm[i].mem != 0) *itm[i].mem[itm[i].arg] = ' ';
  249.             c[GOLD] -= itm[i].price*10;
  250.             itm[i].qty--;  take(itm[i].obj,itm[i].arg);
  251.             if (itm[i].qty==0) dnditem(i);  nap(1001);
  252.             }
  253.         }
  254.  
  255.     }
  256.   }
  257.  
  258. /*
  259.     dnditem(index)
  260.  
  261.     to print the item list;  used in dndstore() enter with the index into itm
  262.  */
  263. static void
  264. dnditem(i)
  265.     register int i;
  266.     {
  267.     register int j,k;
  268.     if (i >= maxitm)  return;
  269.     cursor( (j=(i&1)*40+1) , (k=((i%26)>>1)+5) );
  270.     if (itm[i].qty == 0)  { lprintf("%39s","");  return; }
  271.     lprintf("%c) ",(i%26)+'a');
  272.     if (itm[i].obj == OPOTION)
  273.         { lprcat("potion of "); lprintf("%s",&potionname[itm[i].arg][1]); }
  274.     else if (itm[i].obj == OSCROLL)
  275.         { lprcat("scroll of "); lprintf("%s",&scrollname[itm[i].arg][1]); }
  276.     else lprintf("%s",objectname[itm[i].obj]);
  277.     cursor( j+31,k );  lprintf("%6d",(long)(itm[i].price*10));
  278.     }
  279.  
  280.  
  281. /*
  282.     for the college of larn
  283.  */
  284. char course[26]={0};    /*    the list of courses taken    */
  285. char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
  286. /*
  287.     function to display the header info for the school
  288.  */
  289. sch_hed()
  290.     {
  291.     clear();
  292.     lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
  293.     lprcat("all inhabitants of the caves.  Here is a list of the class schedule:\n\n\n");
  294.     lprcat("\t\t    Course Name \t       Time Needed\n\n");
  295.  
  296.     if (course[0]==0) lprcat("\t\ta)  Fighters Training I         10 mobuls"); /*line 7 of crt*/
  297.     lprc('\n');
  298.     if (course[1]==0) lprcat("\t\tb)  Fighters Training II        15 mobuls");
  299.     lprc('\n');
  300.     if (course[2]==0) lprcat("\t\tc)  Introduction to Wizardry    10 mobuls");
  301.     lprc('\n');
  302.     if (course[3]==0) lprcat("\t\td)  Applied Wizardry            20 mobuls");
  303.     lprc('\n');
  304.     if (course[4]==0) lprcat("\t\te)  Behavioral Psychology       10 mobuls");
  305.     lprc('\n');
  306.     if (course[5]==0) lprcat("\t\tf)  Faith for Today             10 mobuls");
  307.     lprc('\n');
  308.     if (course[6]==0) lprcat("\t\tg)  Contemporary Dance          10 mobuls");
  309.     lprc('\n');
  310.     if (course[7]==0) lprcat("\t\th)  History of Larn              5 mobuls");
  311.  
  312.     lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
  313.     cursor(30,18);
  314.     lprcat("You are presently carrying ");
  315.     }
  316.  
  317. oschool()
  318.     {
  319.     register int i;
  320.     long time_used;
  321.     nosignal = 1; /* disable signals */
  322.     sch_hed();
  323.     while (1)
  324.         {
  325.         cursor(57,18); lprintf("%d gold pieces.   ",(long)c[GOLD]); cursors();
  326.         lprcat("\nWhat is your choice ["); standout("escape");
  327.         lprcat(" to leave] ? ");  yrepcount=0;
  328.         i=0;  while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=getchar();
  329.         if (i==12) { sch_hed();  continue; }
  330.         else if (i=='\33')
  331.             { nosignal = 0; drawscreen();  /* enable signals */ return; }
  332.         lprc(i);
  333.         if (c[GOLD] < 250)  nogold();  else
  334.         if (course[i-'a'])
  335.             { lprcat("\nSorry, but that class is filled."); nap(1000); }
  336.         else
  337.         if (i <= 'h')
  338.             {
  339.             c[GOLD] -= 250; time_used=0;
  340.             switch(i)
  341.                 {
  342.                 case 'a':    c[STRENGTH] += 2;  c[CONSTITUTION]++;
  343.                             lprcat("\nYou feel stronger!");
  344.                             cl_line(16,7);
  345.                             break;
  346.  
  347.                 case 'b':    if (course[0]==0)
  348.                                 {
  349.                                 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
  350.                                 c[GOLD]+=250;  time_used= -10000;  break;
  351.                                 }
  352.                             lprcat("\nYou feel much stronger!");
  353.                             cl_line(16,8);
  354.                             c[STRENGTH] += 2;  c[CONSTITUTION] += 2;  break;
  355.  
  356.                 case 'c':    c[INTELLIGENCE] += 2; 
  357.                             lprcat("\nThe task before you now seems more attainable!");
  358.                             cl_line(16,9);  break;
  359.  
  360.                 case 'd':    if (course[2]==0)
  361.                                 {
  362.                                 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
  363.                                 c[GOLD]+=250;  time_used= -10000;  break;
  364.                                 }
  365.                             lprcat("\nThe task before you now seems very attainable!");
  366.                             cl_line(16,10);
  367.                             c[INTELLIGENCE] += 2;  break;
  368.  
  369.                 case 'e':    c[CHARISMA] += 3;  
  370.                             lprcat("\nYou now feel like a born leader!");
  371.                             cl_line(16,11);  break;
  372.  
  373.                 case 'f':    c[WISDOM] += 2;  
  374.                             lprcat("\nYou now feel more confident that you can find the potion in time!");
  375.                             cl_line(16,12);  break;
  376.  
  377.                 case 'g':    c[DEXTERITY] += 3;  
  378.                             lprcat("\nYou feel like dancing!");
  379.                             cl_line(16,13);  break;
  380.  
  381.                 case 'h':    c[INTELLIGENCE]++;
  382.                             lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
  383.                             lprcat("by a platinum dragon who possesses psionic abilities. ");
  384.                             cl_line(16,14);  break;
  385.                 }
  386.             time_used += coursetime[i-'a']*100;
  387.             if (time_used > 0)
  388.               {
  389.               gtime += time_used;
  390.               course[i-'a']++;    /*    remember that he has taken that course    */
  391.               c[HP] = c[HPMAX];  c[SPELLS] = c[SPELLMAX]; /* he regenerated */ 
  392.  
  393.               if (c[BLINDCOUNT])    c[BLINDCOUNT]=1;  /* cure blindness too!  */
  394.               if (c[CONFUSE])        c[CONFUSE]=1;    /*    end confusion    */
  395.               adjtime((long)time_used);    /* adjust parameters for time change */
  396.               }
  397.             nap(1000);
  398.             }
  399.         }
  400.     }
  401.  
  402. /*
  403.  *    for the first national bank of Larn
  404.  */
  405. int lasttime=0;    /* last time he was in bank */
  406. static void banktitle();
  407.  
  408. obank()
  409.     {
  410.     banktitle("    Welcome to the First National Bank of Larn.");
  411.     }
  412. obank2()
  413.     {
  414.     banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
  415.     }
  416. static void
  417. banktitle(str)
  418.     char *str;
  419.     {
  420.     nosignal = 1; /* disable signals */
  421.     clear();  lprcat(str);
  422.     if (outstanding_taxes>0)
  423.         {
  424.         register int i;
  425.         lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep();
  426.         lprintf("levied taxes have been paid.  They have also told us that you owe %d gp in\n",(long)outstanding_taxes);
  427.         lprcat("taxes, and we must comply with them. We cannot serve you at this time.  Sorry.\n");
  428.         lprcat("We suggest you go to the LRS office and pay your taxes.\n");
  429.         cursors();    
  430.         lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
  431.         i=0;
  432.         while (i!='\33') i=getchar();
  433.         drawscreen();  nosignal = 0; /* enable signals */ return;
  434.         }
  435.     lprcat("\n\n\tGemstone\t      Appraisal\t\tGemstone\t      Appraisal");
  436.     obanksub();        nosignal = 0; /* enable signals */
  437.     drawscreen();
  438.     }
  439.  
  440. /*
  441.  *    function to put interest on your bank account
  442.  */
  443. ointerest()
  444.     {
  445.     register int i;
  446.     if (c[BANKACCOUNT]<0) c[BANKACCOUNT] = 0;
  447.     else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<500000))
  448.         {
  449.         i = (gtime-lasttime)/100; /* # mobuls elapsed */
  450.         while ((i-- > 0) && (c[BANKACCOUNT]<500000))
  451.             c[BANKACCOUNT] += c[BANKACCOUNT]/250;
  452.         if (c[BANKACCOUNT]>500000) c[BANKACCOUNT]=500000; /* interest limit */
  453.         }
  454.     lasttime = (gtime/100)*100;
  455.     }
  456.  
  457. static short gemorder[26]={0};    /* the reference to screen location for each */
  458. static long gemvalue[26]={0};    /* the appraisal of the gems */
  459. obanksub()
  460.     {
  461.     unsigned long amt;
  462.     register int i,k;
  463.     ointerest();    /* credit any needed interest */
  464.  
  465.     for (k=i=0; i<26; i++)
  466.         switch(iven[i])
  467.             {
  468.             case OLARNEYE: case ODIAMOND: case OEMERALD: 
  469.             case ORUBY: case OSAPPHIRE:
  470.  
  471.                     if (iven[i]==OLARNEYE)
  472.                         {
  473.                         gemvalue[i]=250000-((gtime*7)/100)*100;
  474.                         if (gemvalue[i]<50000) gemvalue[i]=50000;
  475.                         }
  476.                     else gemvalue[i] = (255&ivenarg[i])*100;
  477.                     gemorder[i]=k;
  478.                     cursor( (k%2)*40+1 , (k>>1)+4 );
  479.                     lprintf("%c) %s",i+'a',objectname[iven[i]]);
  480.                     cursor( (k%2)*40+33 , (k>>1)+4 );
  481.                     lprintf("%5d",(long)gemvalue[i]);  k++;
  482.             };
  483.     cursor(31,17); lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]);
  484.     cursor(40,18); lprintf("You have %8d gold pieces",(long)c[GOLD]);
  485.     if (c[BANKACCOUNT]+c[GOLD] >= 500000)
  486.         lprcat("\nNote:  Larndom law states that only deposits under 500,000gp  can earn interest.");
  487.     while (1)
  488.         {
  489.         cl_dn(1,20);
  490.         lprcat("\nYour wish? [("); standout("d"); lprcat(") deposit, (");
  491.         standout("w"); lprcat(") withdraw, ("); standout("s");
  492.         lprcat(") sell a stone, or "); standout("escape"); lprcat("]  ");
  493.         yrepcount=0;
  494.         i=0; while (i!='d' && i!='w' && i!='s' && i!='\33') i=getchar();
  495.         switch(i)
  496.             {
  497.             case 'd':    lprcat("deposit\nHow much? ");    amt = readnum((long)c[GOLD]);
  498.                         if (amt<0) { lprcat("\nSorry, but we can't take negative gold!"); nap(2000); amt=0; } else
  499.                         if (amt>c[GOLD])
  500.                           { lprcat("  You don't have that much.");  nap(2000); }
  501.                         else { c[GOLD] -= amt;  c[BANKACCOUNT] += amt; }
  502.                         break;
  503.  
  504.             case 'w':    lprcat("withdraw\nHow much? ");    amt = readnum((long)c[BANKACCOUNT]);
  505.                         if (amt<0) { lprcat("\nSorry, but we don't have any negative gold!");  nap(2000); amt=0; }
  506.                         else if (amt > c[BANKACCOUNT])
  507.                           { lprcat("\nYou don't have that much in the bank!"); nap(2000); }
  508.                         else { c[GOLD] += amt;  c[BANKACCOUNT] -= amt; }        
  509.                         break;
  510.  
  511.             case 's':    lprcat("\nWhich stone would you like to sell? ");
  512.                         i=0; while ((i<'a' || i>'z') && i!='*') i=getchar();
  513.                         if (i=='*')
  514.                           for (i=0; i<26; i++)
  515.                             {
  516.                             if (gemvalue[i]) 
  517.                                 {
  518.                                 c[GOLD]+=gemvalue[i];  iven[i]=0;
  519.                                 gemvalue[i]=0;    k = gemorder[i];
  520.                                 cursor( (k%2)*40+1 , (k>>1)+4 );
  521.                                 lprintf("%39s","");
  522.                                 }
  523.                             }
  524.                         else
  525.                             {
  526.                             if (gemvalue[i=i-'a']==0) 
  527.                                 {
  528.                                 lprintf("\nItem %c is not a gemstone!",i+'a');
  529.                                 nap(2000); break;
  530.                                 }
  531.                             c[GOLD]+=gemvalue[i];  iven[i]=0;
  532.                             gemvalue[i]=0;    k = gemorder[i];
  533.                             cursor( (k%2)*40+1 , (k>>1)+4 ); lprintf("%39s","");
  534.                             }
  535.                         break;
  536.  
  537.             case '\33':    return;
  538.             };
  539.         cursor(40,17); lprintf("%8d",(long)c[BANKACCOUNT]);
  540.         cursor(49,18); lprintf("%8d",(long)c[GOLD]);
  541.         }
  542.     }
  543.  
  544. /*
  545.     subroutine to appraise any stone for the bank
  546.  */
  547. appraise(gemstone)
  548.     register int gemstone;
  549.     {
  550.     register int j,amt;
  551.     for (j=0; j<26; j++)
  552.       if (iven[j]==gemstone)
  553.         {
  554.         lprintf("\nI see you have %s",objectname[gemstone]);
  555.         if (gemstone==OLARNEYE) lprcat("  I must commend you.  I didn't think\nyou could get it.");
  556.         lprcat("  Shall I appraise it for you? ");  yrepcount=0;
  557.         if (getyn()=='y')
  558.             {
  559.             lprcat("yes.\n  Just one moment please \n");  nap(1000);
  560.             if (gemstone==OLARNEYE)
  561.                 {
  562.                 amt = 250000-((gtime*7)/100)*100;
  563.                 if (amt<50000) amt=50000;
  564.                 }
  565.             else amt = (255 & ivenarg[j]) * 100;
  566.             lprintf("\nI can see this is an excellent stone, It is worth %d",(long)amt);
  567.             lprcat("\nWould you like to sell it to us? ");  yrepcount=0;
  568.             if (getyn()=='y') { lprcat("yes\n"); c[GOLD]+=amt;  iven[j]=0; }
  569.             else lprcat("no thank you.\n");
  570.             if (gemstone==OLARNEYE) lprcat("It is, of course, your privilege to keep the stone\n"); 
  571.             }
  572.         else lprcat("no\nO. K.\n");
  573.         }
  574.     }
  575. /*
  576.     function for the trading post
  577.  */
  578. static otradhead()
  579.     {
  580.     clear();
  581.     lprcat("Welcome to the Larn Trading Post.  We buy items that explorers no longer find\n");
  582.     lprcat("useful.  Since the condition of the items you bring in is not certain,\n");
  583.     lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
  584.     lprcat("only 20% of their value were they to be new.  If the items are badly\n");
  585.     lprcat("damaged, we will pay only 10% of their new value.\n\n");
  586.     }
  587.  
  588. otradepost()
  589.   {
  590.   register int i,j,value,isub,izarg;
  591.   dnditm = dndcount = 0;
  592.   nosignal = 1; /* disable signals */
  593.   resetscroll();    otradhead();
  594.   while (1)
  595.     {
  596.     lprcat("\nWhat item do you want to sell to us ["); standout("*");
  597.     lprcat(" for list, or "); standout("escape"); lprcat("] ? ");
  598.     i=0; while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.')) i=getchar();
  599.     if (i == '\33')
  600.         { setscroll(); recalc(); drawscreen(); nosignal=0; /* enable signals */ return; }
  601.     isub = i - 'a';        j=0;
  602.     if (iven[isub]==OSCROLL) if (scrollname[ivenarg[isub]][0]==0)
  603.         { j=1; cnsitm(); }    /* can't sell unidentified item */
  604.     if (iven[isub]==OPOTION) if (potionname[ivenarg[isub]][0]==0)
  605.         { j=1; cnsitm(); }    /* can't sell unidentified item */
  606.     if (!j)
  607.       if (i=='*') { clear(); qshowstr(); otradhead(); }
  608.     else  if (iven[isub]==0)  lprintf("\nYou don't have item %c!",isub+'a');
  609.     else
  610.         {
  611.         for (j=0; j<maxitm; j++)
  612.           if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
  613.             {
  614.             srcount=0;  show3(isub);    /* show what the item was */
  615.             if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
  616.                 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
  617.                 value = 20*ivenarg[isub];
  618.             else
  619.             if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION))  value = 2*itm[j+ivenarg[isub]].price;
  620.             else
  621.                 {
  622.                 izarg=ivenarg[isub];  value = itm[j].price;    /* appreciate if a +n object */
  623.                 if (izarg >= 0) value *= 2;
  624.                 while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000));
  625.                 }
  626.             lprintf("\nItem (%c) is worth %d gold pieces to us.  Do you want to sell it? ",i,(long)value);
  627.             yrepcount=0;
  628.             if (getyn()=='y')
  629.                 {
  630.                 lprcat("yes\n"); c[GOLD]+=value;
  631.                 if (c[WEAR] == isub) c[WEAR] = -1;
  632.                 if (c[WIELD] == isub) c[WIELD] = -1;
  633.                 if (c[SHIELD] == isub) c[SHIELD] = -1;
  634.                 adjustcvalues(iven[isub],ivenarg[isub]);
  635.                 iven[isub]=0;
  636.                 }
  637.             else lprcat("no thanks.\n");
  638.             j = maxitm+100;    /* get out of the inner loop */
  639.             }
  640.         if (j <= maxitm+2) lprcat("\nSo sorry, but we are not authorized to accept that item.");
  641.         }
  642.     }
  643.   }
  644.  
  645. cnsitm()
  646.     { lprcat("\nSorry, we can't accept unidentified objects."); }
  647.  
  648. /*
  649.  *    for the Larn Revenue Service
  650.  */
  651. olrs()
  652.     {
  653.     register int i,first;
  654.     unsigned long amt;
  655.     first = nosignal = 1; /* disable signals */
  656.     clear();  resetscroll(); cursor(1,4);
  657.     lprcat("Welcome to the Larn Revenue Service district office.  How can we help you?");
  658.     while (1)
  659.         {
  660.         if (first) { first=0; goto nxt; }
  661.         cursors();
  662.         lprcat("\n\nYour wish? [(");
  663.         standout("p");
  664.         lprcat(") pay taxes, or ");
  665.         standout("escape");
  666.         lprcat("]  ");  yrepcount=0;
  667.         i=0; while (i!='p' && i!='\33') i=getchar();
  668.         switch(i)
  669.             {
  670.             case 'p':    lprcat("pay taxes\nHow much? "); amt = readnum((long)c[GOLD]);
  671.                         if (amt<0) { lprcat("\nSorry, but we can't take negative gold\n"); amt=0; } else
  672.                         if (amt>c[GOLD])    lprcat("  You don't have that much.\n");
  673.                         else  c[GOLD] -= paytaxes((long)amt);
  674.                         break;
  675.  
  676.             case '\33':    nosignal = 0; /* enable signals */
  677.                         setscroll(); drawscreen();    return;
  678.             };
  679.  
  680. nxt:    cursor(1,6);
  681.         if (outstanding_taxes>0)
  682.             lprintf("You presently owe %d gp in taxes.  ",(long)outstanding_taxes);
  683.         else
  684.             lprcat("You do not owe us any taxes.           ");
  685.         cursor(1,8);
  686.         if (c[GOLD]>0)
  687.             lprintf("You have %6d gp.    ",(long)c[GOLD]);
  688.         else
  689.             lprcat("You have no gold pieces.  ");
  690.         }
  691.     }
  692.