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