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