]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/store.c
gtime -> gltime to avoid conflict in time.h
[bsdgames-darwin.git] / larn / store.c
1 /* $NetBSD: store.c,v 1.5 1997/07/13 20:21:41 christos 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.5 1997/07/13 20:21:41 christos 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 \f
290 /*
291 for the college of larn
292 */
293 char course[26]={0}; /* the list of courses taken */
294 char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
295 /*
296 function to display the header info for the school
297 */
298 sch_hed()
299 {
300 clear();
301 lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
302 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n");
303 lprcat("\t\t Course Name \t Time Needed\n\n");
304
305 if (course[0]==0) lprcat("\t\ta) Fighters Training I 10 mobuls"); /*line 7 of crt*/
306 lprc('\n');
307 if (course[1]==0) lprcat("\t\tb) Fighters Training II 15 mobuls");
308 lprc('\n');
309 if (course[2]==0) lprcat("\t\tc) Introduction to Wizardry 10 mobuls");
310 lprc('\n');
311 if (course[3]==0) lprcat("\t\td) Applied Wizardry 20 mobuls");
312 lprc('\n');
313 if (course[4]==0) lprcat("\t\te) Behavioral Psychology 10 mobuls");
314 lprc('\n');
315 if (course[5]==0) lprcat("\t\tf) Faith for Today 10 mobuls");
316 lprc('\n');
317 if (course[6]==0) lprcat("\t\tg) Contemporary Dance 10 mobuls");
318 lprc('\n');
319 if (course[7]==0) lprcat("\t\th) History of Larn 5 mobuls");
320
321 lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
322 cursor(30,18);
323 lprcat("You are presently carrying ");
324 }
325
326 oschool()
327 {
328 register int i;
329 long time_used;
330 nosignal = 1; /* disable signals */
331 sch_hed();
332 while (1)
333 {
334 cursor(57,18); lprintf("%d gold pieces. ",(long)c[GOLD]); cursors();
335 lprcat("\nWhat is your choice ["); standout("escape");
336 lprcat(" to leave] ? "); yrepcount=0;
337 i=0; while ((i<'a' || i>'h') && (i!='\33') && (i!=12)) i=getchar();
338 if (i==12) { sch_hed(); continue; }
339 else if (i=='\33')
340 { nosignal = 0; drawscreen(); /* enable signals */ return; }
341 lprc(i);
342 if (c[GOLD] < 250) nogold(); else
343 if (course[i-'a'])
344 { lprcat("\nSorry, but that class is filled."); nap(1000); }
345 else
346 if (i <= 'h')
347 {
348 c[GOLD] -= 250; time_used=0;
349 switch(i)
350 {
351 case 'a': c[STRENGTH] += 2; c[CONSTITUTION]++;
352 lprcat("\nYou feel stronger!");
353 cl_line(16,7);
354 break;
355
356 case 'b': if (course[0]==0)
357 {
358 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
359 c[GOLD]+=250; time_used= -10000; break;
360 }
361 lprcat("\nYou feel much stronger!");
362 cl_line(16,8);
363 c[STRENGTH] += 2; c[CONSTITUTION] += 2; break;
364
365 case 'c': c[INTELLIGENCE] += 2;
366 lprcat("\nThe task before you now seems more attainable!");
367 cl_line(16,9); break;
368
369 case 'd': if (course[2]==0)
370 {
371 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
372 c[GOLD]+=250; time_used= -10000; break;
373 }
374 lprcat("\nThe task before you now seems very attainable!");
375 cl_line(16,10);
376 c[INTELLIGENCE] += 2; break;
377
378 case 'e': c[CHARISMA] += 3;
379 lprcat("\nYou now feel like a born leader!");
380 cl_line(16,11); break;
381
382 case 'f': c[WISDOM] += 2;
383 lprcat("\nYou now feel more confident that you can find the potion in time!");
384 cl_line(16,12); break;
385
386 case 'g': c[DEXTERITY] += 3;
387 lprcat("\nYou feel like dancing!");
388 cl_line(16,13); break;
389
390 case 'h': c[INTELLIGENCE]++;
391 lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
392 lprcat("by a platinum dragon who possesses psionic abilities. ");
393 cl_line(16,14); break;
394 }
395 time_used += coursetime[i-'a']*100;
396 if (time_used > 0)
397 {
398 gltime += time_used;
399 course[i-'a']++; /* remember that he has taken that course */
400 c[HP] = c[HPMAX]; c[SPELLS] = c[SPELLMAX]; /* he regenerated */
401
402 if (c[BLINDCOUNT]) c[BLINDCOUNT]=1; /* cure blindness too! */
403 if (c[CONFUSE]) c[CONFUSE]=1; /* end confusion */
404 adjtime((long)time_used); /* adjust parameters for time change */
405 }
406 nap(1000);
407 }
408 }
409 }
410 \f
411 /*
412 * for the first national bank of Larn
413 */
414 int lasttime=0; /* last time he was in bank */
415 static void banktitle();
416
417 obank()
418 {
419 banktitle(" Welcome to the First National Bank of Larn.");
420 }
421 obank2()
422 {
423 banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
424 }
425 static void
426 banktitle(str)
427 char *str;
428 {
429 nosignal = 1; /* disable signals */
430 clear(); lprcat(str);
431 if (outstanding_taxes>0)
432 {
433 register int i;
434 lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n"); beep();
435 lprintf("levied taxes have been paid. They have also told us that you owe %d gp in\n",(long)outstanding_taxes);
436 lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n");
437 lprcat("We suggest you go to the LRS office and pay your taxes.\n");
438 cursors();
439 lprcat("\nPress "); standout("escape"); lprcat(" to leave: "); lflush();
440 i=0;
441 while (i!='\33') i=getchar();
442 drawscreen(); nosignal = 0; /* enable signals */ return;
443 }
444 lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
445 obanksub(); nosignal = 0; /* enable signals */
446 drawscreen();
447 }
448
449 /*
450 * function to put interest on your bank account
451 */
452 ointerest()
453 {
454 register int i;
455 if (c[BANKACCOUNT]<0) c[BANKACCOUNT] = 0;
456 else if ((c[BANKACCOUNT]>0) && (c[BANKACCOUNT]<500000))
457 {
458 i = (gltime-lasttime)/100; /* # mobuls elapsed */
459 while ((i-- > 0) && (c[BANKACCOUNT]<500000))
460 c[BANKACCOUNT] += c[BANKACCOUNT]/250;
461 if (c[BANKACCOUNT]>500000) c[BANKACCOUNT]=500000; /* interest limit */
462 }
463 lasttime = (gltime/100)*100;
464 }
465
466 static short gemorder[26]={0}; /* the reference to screen location for each */
467 static long gemvalue[26]={0}; /* the appraisal of the gems */
468 obanksub()
469 {
470 unsigned long amt;
471 register int i,k;
472 ointerest(); /* credit any needed interest */
473
474 for (k=i=0; i<26; i++)
475 switch(iven[i])
476 {
477 case OLARNEYE: case ODIAMOND: case OEMERALD:
478 case ORUBY: case OSAPPHIRE:
479
480 if (iven[i]==OLARNEYE)
481 {
482 gemvalue[i]=250000-((gltime*7)/100)*100;
483 if (gemvalue[i]<50000) gemvalue[i]=50000;
484 }
485 else gemvalue[i] = (255&ivenarg[i])*100;
486 gemorder[i]=k;
487 cursor( (k%2)*40+1 , (k>>1)+4 );
488 lprintf("%c) %s",i+'a',objectname[iven[i]]);
489 cursor( (k%2)*40+33 , (k>>1)+4 );
490 lprintf("%5d",(long)gemvalue[i]); k++;
491 };
492 cursor(31,17); lprintf("You have %8d gold pieces in the bank.",(long)c[BANKACCOUNT]);
493 cursor(40,18); lprintf("You have %8d gold pieces",(long)c[GOLD]);
494 if (c[BANKACCOUNT]+c[GOLD] >= 500000)
495 lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest.");
496 while (1)
497 {
498 cl_dn(1,20);
499 lprcat("\nYour wish? [("); standout("d"); lprcat(") deposit, (");
500 standout("w"); lprcat(") withdraw, ("); standout("s");
501 lprcat(") sell a stone, or "); standout("escape"); lprcat("] ");
502 yrepcount=0;
503 i=0; while (i!='d' && i!='w' && i!='s' && i!='\33') i=getchar();
504 switch(i)
505 {
506 case 'd': lprcat("deposit\nHow much? "); amt = readnum((long)c[GOLD]);
507 if (amt<0) { lprcat("\nSorry, but we can't take negative gold!"); nap(2000); amt=0; } else
508 if (amt>c[GOLD])
509 { lprcat(" You don't have that much."); nap(2000); }
510 else { c[GOLD] -= amt; c[BANKACCOUNT] += amt; }
511 break;
512
513 case 'w': lprcat("withdraw\nHow much? "); amt = readnum((long)c[BANKACCOUNT]);
514 if (amt<0) { lprcat("\nSorry, but we don't have any negative gold!"); nap(2000); amt=0; }
515 else if (amt > c[BANKACCOUNT])
516 { lprcat("\nYou don't have that much in the bank!"); nap(2000); }
517 else { c[GOLD] += amt; c[BANKACCOUNT] -= amt; }
518 break;
519
520 case 's': lprcat("\nWhich stone would you like to sell? ");
521 i=0; while ((i<'a' || i>'z') && i!='*') i=getchar();
522 if (i=='*')
523 for (i=0; i<26; i++)
524 {
525 if (gemvalue[i])
526 {
527 c[GOLD]+=gemvalue[i]; iven[i]=0;
528 gemvalue[i]=0; k = gemorder[i];
529 cursor( (k%2)*40+1 , (k>>1)+4 );
530 lprintf("%39s","");
531 }
532 }
533 else
534 {
535 if (gemvalue[i=i-'a']==0)
536 {
537 lprintf("\nItem %c is not a gemstone!",i+'a');
538 nap(2000); break;
539 }
540 c[GOLD]+=gemvalue[i]; iven[i]=0;
541 gemvalue[i]=0; k = gemorder[i];
542 cursor( (k%2)*40+1 , (k>>1)+4 ); lprintf("%39s","");
543 }
544 break;
545
546 case '\33': return;
547 };
548 cursor(40,17); lprintf("%8d",(long)c[BANKACCOUNT]);
549 cursor(49,18); lprintf("%8d",(long)c[GOLD]);
550 }
551 }
552
553 /*
554 subroutine to appraise any stone for the bank
555 */
556 appraise(gemstone)
557 register int gemstone;
558 {
559 register int j,amt;
560 for (j=0; j<26; j++)
561 if (iven[j]==gemstone)
562 {
563 lprintf("\nI see you have %s",objectname[gemstone]);
564 if (gemstone==OLARNEYE) lprcat(" I must commend you. I didn't think\nyou could get it.");
565 lprcat(" Shall I appraise it for you? "); yrepcount=0;
566 if (getyn()=='y')
567 {
568 lprcat("yes.\n Just one moment please \n"); nap(1000);
569 if (gemstone==OLARNEYE)
570 {
571 amt = 250000-((gltime*7)/100)*100;
572 if (amt<50000) amt=50000;
573 }
574 else amt = (255 & ivenarg[j]) * 100;
575 lprintf("\nI can see this is an excellent stone, It is worth %d",(long)amt);
576 lprcat("\nWould you like to sell it to us? "); yrepcount=0;
577 if (getyn()=='y') { lprcat("yes\n"); c[GOLD]+=amt; iven[j]=0; }
578 else lprcat("no thank you.\n");
579 if (gemstone==OLARNEYE) lprcat("It is, of course, your privilege to keep the stone\n");
580 }
581 else lprcat("no\nO. K.\n");
582 }
583 }
584 /*
585 function for the trading post
586 */
587 static otradhead()
588 {
589 clear();
590 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n");
591 lprcat("useful. Since the condition of the items you bring in is not certain,\n");
592 lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
593 lprcat("only 20% of their value were they to be new. If the items are badly\n");
594 lprcat("damaged, we will pay only 10% of their new value.\n\n");
595 }
596
597 otradepost()
598 {
599 register int i,j,value,isub,izarg;
600 dnditm = dndcount = 0;
601 nosignal = 1; /* disable signals */
602 resetscroll(); otradhead();
603 while (1)
604 {
605 lprcat("\nWhat item do you want to sell to us ["); standout("*");
606 lprcat(" for list, or "); standout("escape"); lprcat("] ? ");
607 i=0; while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.')) i=getchar();
608 if (i == '\33')
609 { setscroll(); recalc(); drawscreen(); nosignal=0; /* enable signals */ return; }
610 isub = i - 'a'; j=0;
611 if (iven[isub]==OSCROLL) if (scrollname[ivenarg[isub]][0]==0)
612 { j=1; cnsitm(); } /* can't sell unidentified item */
613 if (iven[isub]==OPOTION) if (potionname[ivenarg[isub]][0]==0)
614 { j=1; cnsitm(); } /* can't sell unidentified item */
615 if (!j)
616 if (i=='*') { clear(); qshowstr(); otradhead(); }
617 else if (iven[isub]==0) lprintf("\nYou don't have item %c!",isub+'a');
618 else
619 {
620 for (j=0; j<maxitm; j++)
621 if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
622 {
623 srcount=0; show3(isub); /* show what the item was */
624 if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
625 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
626 value = 20*ivenarg[isub];
627 else
628 if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION)) value = 2*itm[j+ivenarg[isub]].price;
629 else
630 {
631 izarg=ivenarg[isub]; value = itm[j].price; /* appreciate if a +n object */
632 if (izarg >= 0) value *= 2;
633 while ((izarg-- > 0) && ((value=14*(67+value)/10) < 500000));
634 }
635 lprintf("\nItem (%c) is worth %d gold pieces to us. Do you want to sell it? ",i,(long)value);
636 yrepcount=0;
637 if (getyn()=='y')
638 {
639 lprcat("yes\n"); c[GOLD]+=value;
640 if (c[WEAR] == isub) c[WEAR] = -1;
641 if (c[WIELD] == isub) c[WIELD] = -1;
642 if (c[SHIELD] == isub) c[SHIELD] = -1;
643 adjustcvalues(iven[isub],ivenarg[isub]);
644 iven[isub]=0;
645 }
646 else lprcat("no thanks.\n");
647 j = maxitm+100; /* get out of the inner loop */
648 }
649 if (j <= maxitm+2) lprcat("\nSo sorry, but we are not authorized to accept that item.");
650 }
651 }
652 }
653
654 cnsitm()
655 { lprcat("\nSorry, we can't accept unidentified objects."); }
656
657 /*
658 * for the Larn Revenue Service
659 */
660 olrs()
661 {
662 register int i,first;
663 unsigned long amt;
664 first = nosignal = 1; /* disable signals */
665 clear(); resetscroll(); cursor(1,4);
666 lprcat("Welcome to the Larn Revenue Service district office. How can we help you?");
667 while (1)
668 {
669 if (first) { first=0; goto nxt; }
670 cursors();
671 lprcat("\n\nYour wish? [(");
672 standout("p");
673 lprcat(") pay taxes, or ");
674 standout("escape");
675 lprcat("] "); yrepcount=0;
676 i=0; while (i!='p' && i!='\33') i=getchar();
677 switch(i)
678 {
679 case 'p': lprcat("pay taxes\nHow much? "); amt = readnum((long)c[GOLD]);
680 if (amt<0) { lprcat("\nSorry, but we can't take negative gold\n"); amt=0; } else
681 if (amt>c[GOLD]) lprcat(" You don't have that much.\n");
682 else c[GOLD] -= paytaxes((long)amt);
683 break;
684
685 case '\33': nosignal = 0; /* enable signals */
686 setscroll(); drawscreen(); return;
687 };
688
689 nxt: cursor(1,6);
690 if (outstanding_taxes>0)
691 lprintf("You presently owe %d gp in taxes. ",(long)outstanding_taxes);
692 else
693 lprcat("You do not owe us any taxes. ");
694 cursor(1,8);
695 if (c[GOLD]>0)
696 lprintf("You have %6d gp. ",(long)c[GOLD]);
697 else
698 lprcat("You have no gold pieces. ");
699 }
700 }