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