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