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