Sync usage with man page.
[netbsd-mini2440.git] / games / larn / store.c
blob4ba61ed7d90d79a10b9e9d4a37ac6de38054fbbf
1 /* $NetBSD: store.c,v 1.14 2008/02/03 21:24:59 dholland Exp $ */
3 /*-
4 * Copyright (c) 1988 The Regents of the University of California.
5 * All rights reserved.
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. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 #ifndef lint
34 #if 0
35 static char sccsid[] = "@(#)store.c 5.4 (Berkeley) 5/13/91";
36 #else
37 __RCSID("$NetBSD: store.c,v 1.14 2008/02/03 21:24:59 dholland Exp $");
38 #endif
39 #endif /* not lint */
41 /* store.c Larn is copyrighted 1986 by Noah Morgan. */
42 #include "header.h"
43 #include "extern.h"
45 static void handsfull(void);
46 static void outofstock(void);
47 static void nogold(void);
48 static void dnditem(int);
49 static void banktitle(const char *);
50 static void obanksub(void);
51 static void otradhead(void);
52 static void cnsitm(void);
54 static int dndcount = 0, dnditm = 0;
56 /* number of items in the dnd inventory table */
57 #define MAXITM 83
59 /* this is the data for the stuff in the dnd store */
60 struct _itm itm[90] = {
62 * cost iven name iven arg how gp
63 * iven[] ivenarg[] many
66 {2, OLEATHER, 0, 3},
67 {10, OSTUDLEATHER, 0, 2},
68 {40, ORING, 0, 2},
69 {85, OCHAIN, 0, 2},
70 {220, OSPLINT, 0, 1},
71 {400, OPLATE, 0, 1},
72 {900, OPLATEARMOR, 0, 1},
73 {2600, OSSPLATE, 0, 1},
74 {150, OSHIELD, 0, 1},
77 * cost iven name iven arg how gp
78 * iven[] ivenarg[] many
81 {2, ODAGGER, 0, 3},
82 {20, OSPEAR, 0, 3},
83 {80, OFLAIL, 0, 2},
84 {150, OBATTLEAXE, 0, 2},
85 {450, OLONGSWORD, 0, 2},
86 {1000, O2SWORD, 0, 2},
87 {5000, OSWORD, 0, 1},
88 {16500, OLANCE, 0, 1},
89 {6000, OSWORDofSLASHING, 0, 0},
90 {10000, OHAMMER, 0, 0},
93 * cost iven name iven arg how gp
94 * iven[] ivenarg[] many
97 {150, OPROTRING, 1, 1},
98 {85, OSTRRING, 1, 1},
99 {120, ODEXRING, 1, 1},
100 {120, OCLEVERRING, 1, 1},
101 {180, OENERGYRING, 0, 1},
102 {125, ODAMRING, 0, 1},
103 {220, OREGENRING, 0, 1},
104 {1000, ORINGOFEXTRA, 0, 1},
106 {280, OBELT, 0, 1},
108 {400, OAMULET, 0, 1},
110 {6500, OORBOFDRAGON, 0, 0},
111 {5500, OSPIRITSCARAB, 0, 0},
112 {5000, OCUBEofUNDEAD, 0, 0},
113 {6000, ONOTHEFT, 0, 0},
115 {590, OCHEST, 6, 1},
116 {200, OBOOK, 8, 1},
117 {10, OCOOKIE, 0, 3},
120 * cost iven name iven arg how gp
121 * iven[] ivenarg[] many
124 {20, OPOTION, 0, 6},
125 {90, OPOTION, 1, 5},
126 {520, OPOTION, 2, 1},
127 {100, OPOTION, 3, 2},
128 {50, OPOTION, 4, 2},
129 {150, OPOTION, 5, 2},
130 {70, OPOTION, 6, 1},
131 {30, OPOTION, 7, 7},
132 {200, OPOTION, 8, 1},
133 {50, OPOTION, 9, 1},
134 {80, OPOTION, 10, 1},
137 * cost iven name iven arg how gp
138 * iven[] ivenarg[] many
141 {30, OPOTION, 11, 3},
142 {20, OPOTION, 12, 5},
143 {40, OPOTION, 13, 3},
144 {35, OPOTION, 14, 2},
145 {520, OPOTION, 15, 1},
146 {90, OPOTION, 16, 2},
147 {200, OPOTION, 17, 2},
148 {220, OPOTION, 18, 4},
149 {80, OPOTION, 19, 6},
150 {370, OPOTION, 20, 3},
151 {50, OPOTION, 22, 1},
152 {150, OPOTION, 23, 3},
155 * cost iven name iven arg how gp
156 * iven[] ivenarg[] many
159 {100, OSCROLL, 0, 2},
160 {125, OSCROLL, 1, 2},
161 {60, OSCROLL, 2, 4},
162 {10, OSCROLL, 3, 4},
163 {100, OSCROLL, 4, 3},
164 {200, OSCROLL, 5, 2},
165 {110, OSCROLL, 6, 1},
166 {500, OSCROLL, 7, 2},
167 {200, OSCROLL, 8, 2},
168 {250, OSCROLL, 9, 4},
169 {20, OSCROLL, 10, 5},
170 {30, OSCROLL, 11, 3},
173 * cost iven name iven arg how gp
174 * iven[] ivenarg[] many
177 {340, OSCROLL, 12, 1},
178 {340, OSCROLL, 13, 1},
179 {300, OSCROLL, 14, 2},
180 {400, OSCROLL, 15, 2},
181 {500, OSCROLL, 16, 2},
182 {1000, OSCROLL, 17, 1},
183 {500, OSCROLL, 18, 1},
184 {340, OSCROLL, 19, 2},
185 {220, OSCROLL, 20, 3},
186 {3900, OSCROLL, 21, 0},
187 {610, OSCROLL, 22, 1},
188 {3000, OSCROLL, 23, 0}
192 function for the dnd store
194 static void
195 dnd_2hed(void)
197 lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n");
198 lprcat(" in their adventures. Feel free to browse to your hearts content.\n");
199 lprcat("Also be advised, if you break 'em, you pay for 'em.");
202 static void
203 dnd_hed(void)
205 int i;
206 for (i = dnditm; i < 26 + dnditm; i++)
207 dnditem(i);
208 cursor(50, 18);
209 lprcat("You have ");
212 static void
213 handsfull()
215 lprcat("\nYou can't carry anything more!");
216 lflush();
217 nap(2200);
220 static void
221 outofstock()
223 lprcat("\nSorry, but we are out of that item.");
224 lflush();
225 nap(2200);
228 static void
229 nogold()
231 lprcat("\nYou don't have enough gold to pay for that!");
232 lflush();
233 nap(2200);
236 void
237 dndstore()
239 int i;
240 dnditm = 0;
241 nosignal = 1; /* disable signals */
242 clear();
243 dnd_2hed();
244 if (outstanding_taxes > 0) {
245 lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n");
246 beep();
247 lprintf("They have also told us that you owe %ld gp in back taxes, and as we must\n", (long) outstanding_taxes);
248 lprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n");
249 cursors();
250 lprcat("\nPress ");
251 standout("escape");
252 lprcat(" to leave: ");
253 lflush();
254 i = 0;
255 while (i != '\33')
256 i = ttgetch();
257 drawscreen();
258 nosignal = 0; /* enable signals */
259 return;
261 dnd_hed();
262 while (1) {
263 cursor(59, 18);
264 lprintf("%ld gold pieces", (long) c[GOLD]);
265 cltoeoln();
266 cl_dn(1, 20); /* erase to eod */
267 lprcat("\nEnter your transaction [");
268 standout("space");
269 lprcat(" for more, ");
270 standout("escape");
271 lprcat(" to leave]? ");
272 i = 0;
273 while ((i < 'a' || i > 'z') && (i != ' ') && (i != '\33') && (i != 12))
274 i = ttgetch();
275 if (i == 12) {
276 clear();
277 dnd_2hed();
278 dnd_hed();
279 } else if (i == '\33') {
280 drawscreen();
281 nosignal = 0; /* enable signals */
282 return;
283 } else if (i == ' ') {
284 cl_dn(1, 4);
285 if ((dnditm += 26) >= MAXITM)
286 dnditm = 0;
287 dnd_hed();
288 } else { /* buy something */
289 lprc(i);/* echo the byte */
290 i += dnditm - 'a';
291 if (i >= MAXITM)
292 outofstock();
293 else if (itm[i].qty <= 0)
294 outofstock();
295 else if (pocketfull())
296 handsfull();
297 else if (c[GOLD] < itm[i].price * 10)
298 nogold();
299 else {
300 if (itm[i].obj == OPOTION) {
301 potionname[itm[i].arg] = potionhide[itm[i].arg];
302 } else if (itm[i].obj == OSCROLL) {
303 scrollname[itm[i].arg] = scrollhide[itm[i].arg];
305 c[GOLD] -= itm[i].price * 10;
306 itm[i].qty--;
307 take(itm[i].obj, itm[i].arg);
308 if (itm[i].qty == 0)
309 dnditem(i);
310 nap(1001);
318 dnditem(index)
320 to print the item list; used in dndstore() enter with the index into itm
322 static void
323 dnditem(i)
324 int i;
326 int j, k;
327 if (i >= MAXITM)
328 return;
329 cursor((j = (i & 1) * 40 + 1), (k = ((i % 26) >> 1) + 5));
330 if (itm[i].qty == 0) {
331 lprintf("%39s", "");
332 return;
334 lprintf("%c) ", (i % 26) + 'a');
335 if (itm[i].obj == OPOTION) {
336 lprintf("potion of%s", potionhide[itm[i].arg]);
337 } else if (itm[i].obj == OSCROLL) {
338 lprintf("scroll of%s", scrollhide[itm[i].arg]);
339 } else
340 lprintf("%s", objectname[itm[i].obj]);
341 cursor(j + 31, k);
342 lprintf("%6ld", (long) (itm[i].price * 10));
348 for the college of larn
350 u_char course[26] = {0}; /* the list of courses taken */
351 static char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5};
353 function to display the header info for the school
355 static void
356 sch_hed(void)
358 clear();
359 lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
360 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n");
361 lprcat("\t\t Course Name \t Time Needed\n\n");
363 if (course[0] == 0)
364 lprcat("\t\ta) Fighters Training I 10 mobuls"); /* line 7 of crt */
365 lprc('\n');
366 if (course[1] == 0)
367 lprcat("\t\tb) Fighters Training II 15 mobuls");
368 lprc('\n');
369 if (course[2] == 0)
370 lprcat("\t\tc) Introduction to Wizardry 10 mobuls");
371 lprc('\n');
372 if (course[3] == 0)
373 lprcat("\t\td) Applied Wizardry 20 mobuls");
374 lprc('\n');
375 if (course[4] == 0)
376 lprcat("\t\te) Behavioral Psychology 10 mobuls");
377 lprc('\n');
378 if (course[5] == 0)
379 lprcat("\t\tf) Faith for Today 10 mobuls");
380 lprc('\n');
381 if (course[6] == 0)
382 lprcat("\t\tg) Contemporary Dance 10 mobuls");
383 lprc('\n');
384 if (course[7] == 0)
385 lprcat("\t\th) History of Larn 5 mobuls");
387 lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
388 cursor(30, 18);
389 lprcat("You are presently carrying ");
392 void
393 oschool()
395 int i;
396 long time_used;
397 nosignal = 1; /* disable signals */
398 sch_hed();
399 while (1) {
400 cursor(57, 18);
401 lprintf("%ld gold pieces. ", (long) c[GOLD]);
402 cursors();
403 lprcat("\nWhat is your choice [");
404 standout("escape");
405 lprcat(" to leave] ? ");
406 yrepcount = 0;
407 i = 0;
408 while ((i < 'a' || i > 'h') && (i != '\33') && (i != 12))
409 i = ttgetch();
410 if (i == 12) {
411 sch_hed();
412 continue;
413 } else if (i == '\33') {
414 nosignal = 0;
415 drawscreen(); /* enable signals */
416 return;
418 lprc(i);
419 if (c[GOLD] < 250)
420 nogold();
421 else if (course[i - 'a']) {
422 lprcat("\nSorry, but that class is filled.");
423 nap(1000);
424 } else if (i <= 'h') {
425 c[GOLD] -= 250;
426 time_used = 0;
427 switch (i) {
428 case 'a':
429 c[STRENGTH] += 2;
430 c[CONSTITUTION]++;
431 lprcat("\nYou feel stronger!");
432 cl_line(16, 7);
433 break;
435 case 'b':
436 if (course[0] == 0) {
437 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
438 c[GOLD] += 250;
439 time_used = -10000;
440 break;
442 lprcat("\nYou feel much stronger!");
443 cl_line(16, 8);
444 c[STRENGTH] += 2;
445 c[CONSTITUTION] += 2;
446 break;
448 case 'c':
449 c[INTELLIGENCE] += 2;
450 lprcat("\nThe task before you now seems more attainable!");
451 cl_line(16, 9);
452 break;
454 case 'd':
455 if (course[2] == 0) {
456 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
457 c[GOLD] += 250;
458 time_used = -10000;
459 break;
461 lprcat("\nThe task before you now seems very attainable!");
462 cl_line(16, 10);
463 c[INTELLIGENCE] += 2;
464 break;
466 case 'e':
467 c[CHARISMA] += 3;
468 lprcat("\nYou now feel like a born leader!");
469 cl_line(16, 11);
470 break;
472 case 'f':
473 c[WISDOM] += 2;
474 lprcat("\nYou now feel more confident that you can find the potion in time!");
475 cl_line(16, 12);
476 break;
478 case 'g':
479 c[DEXTERITY] += 3;
480 lprcat("\nYou feel like dancing!");
481 cl_line(16, 13);
482 break;
484 case 'h':
485 c[INTELLIGENCE]++;
486 lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
487 lprcat("by a platinum dragon who possesses psionic abilities. ");
488 cl_line(16, 14);
489 break;
491 time_used += coursetime[i - 'a'] * 100;
492 if (time_used > 0) {
493 gltime += time_used;
494 course[i - 'a']++; /* remember that he has
495 * taken that course */
496 c[HP] = c[HPMAX];
497 c[SPELLS] = c[SPELLMAX]; /* he regenerated */
499 if (c[BLINDCOUNT])
500 c[BLINDCOUNT] = 1; /* cure blindness too! */
501 if (c[CONFUSE])
502 c[CONFUSE] = 1; /* end confusion */
503 adjusttime((long) time_used); /* adjust parameters for
504 * time change */
506 nap(1000);
513 * for the first national bank of Larn
515 int lasttime = 0; /* last time he was in bank */
517 void
518 obank()
520 banktitle(" Welcome to the First National Bank of Larn.");
522 void
523 obank2()
525 banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
528 static void
529 banktitle(const char *str)
531 nosignal = 1; /* disable signals */
532 clear();
533 lprcat(str);
534 if (outstanding_taxes > 0) {
535 int i;
536 lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n");
537 beep();
538 lprintf("levied taxes have been paid. They have also told us that you owe %ld gp in\n", (long) outstanding_taxes);
539 lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n");
540 lprcat("We suggest you go to the LRS office and pay your taxes.\n");
541 cursors();
542 lprcat("\nPress ");
543 standout("escape");
544 lprcat(" to leave: ");
545 lflush();
546 i = 0;
547 while (i != '\33')
548 i = ttgetch();
549 drawscreen();
550 nosignal = 0; /* enable signals */
551 return;
553 lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
554 obanksub();
555 nosignal = 0; /* enable signals */
556 drawscreen();
560 * function to put interest on your bank account
562 void
563 ointerest()
565 int i;
566 if (c[BANKACCOUNT] < 0)
567 c[BANKACCOUNT] = 0;
568 else if ((c[BANKACCOUNT] > 0) && (c[BANKACCOUNT] < 500000)) {
569 i = (gltime - lasttime) / 100; /* # mobuls elapsed */
570 while ((i-- > 0) && (c[BANKACCOUNT] < 500000))
571 c[BANKACCOUNT] += c[BANKACCOUNT] / 250;
572 if (c[BANKACCOUNT] > 500000)
573 c[BANKACCOUNT] = 500000; /* interest limit */
575 lasttime = (gltime / 100) * 100;
578 static short gemorder[26] = {0}; /* the reference to screen location
579 * for each */
580 static long gemvalue[26] = {0}; /* the appraisal of the gems */
581 void
582 obanksub()
584 long amt;
585 int i, k;
586 ointerest(); /* credit any needed interest */
588 for (k = i = 0; i < 26; i++)
589 switch (iven[i]) {
590 case OLARNEYE:
591 case ODIAMOND:
592 case OEMERALD:
593 case ORUBY:
594 case OSAPPHIRE:
596 if (iven[i] == OLARNEYE) {
597 gemvalue[i] = 250000 - ((gltime * 7) / 100) * 100;
598 if (gemvalue[i] < 50000)
599 gemvalue[i] = 50000;
600 } else
601 gemvalue[i] = (255 & ivenarg[i]) * 100;
602 gemorder[i] = k;
603 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
604 lprintf("%c) %s", i + 'a', objectname[iven[i]]);
605 cursor((k % 2) * 40 + 33, (k >> 1) + 4);
606 lprintf("%5ld", (long) gemvalue[i]);
607 k++;
609 cursor(31, 17);
610 lprintf("You have %8ld gold pieces in the bank.", (long) c[BANKACCOUNT]);
611 cursor(40, 18);
612 lprintf("You have %8ld gold pieces", (long) c[GOLD]);
613 if (c[BANKACCOUNT] + c[GOLD] >= 500000)
614 lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest.");
615 while (1) {
616 cl_dn(1, 20);
617 lprcat("\nYour wish? [(");
618 standout("d");
619 lprcat(") deposit, (");
620 standout("w");
621 lprcat(") withdraw, (");
622 standout("s");
623 lprcat(") sell a stone, or ");
624 standout("escape");
625 lprcat("] ");
626 yrepcount = 0;
627 i = 0;
628 while (i != 'd' && i != 'w' && i != 's' && i != '\33')
629 i = ttgetch();
630 switch (i) {
631 case 'd':
632 lprcat("deposit\nHow much? ");
633 amt = readnum((long) c[GOLD]);
634 if (amt < 0) {
635 lprcat("\nSorry, but we can't take negative gold!");
636 nap(2000);
637 amt = 0;
638 } else if (amt > c[GOLD]) {
639 lprcat(" You don't have that much.");
640 nap(2000);
641 } else {
642 c[GOLD] -= amt;
643 c[BANKACCOUNT] += amt;
645 break;
647 case 'w':
648 lprcat("withdraw\nHow much? ");
649 amt = readnum((long) c[BANKACCOUNT]);
650 if (amt < 0) {
651 lprcat("\nSorry, but we don't have any negative gold!");
652 nap(2000);
653 amt = 0;
654 } else if (amt > c[BANKACCOUNT]) {
655 lprcat("\nYou don't have that much in the bank!");
656 nap(2000);
657 } else {
658 c[GOLD] += amt;
659 c[BANKACCOUNT] -= amt;
661 break;
663 case 's':
664 lprcat("\nWhich stone would you like to sell? ");
665 i = 0;
666 while ((i < 'a' || i > 'z') && i != '*')
667 i = ttgetch();
668 if (i == '*')
669 for (i = 0; i < 26; i++) {
670 if (gemvalue[i]) {
671 c[GOLD] += gemvalue[i];
672 iven[i] = 0;
673 gemvalue[i] = 0;
674 k = gemorder[i];
675 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
676 lprintf("%39s", "");
679 else {
680 if (gemvalue[i = i - 'a'] == 0) {
681 lprintf("\nItem %c is not a gemstone!", i + 'a');
682 nap(2000);
683 break;
685 c[GOLD] += gemvalue[i];
686 iven[i] = 0;
687 gemvalue[i] = 0;
688 k = gemorder[i];
689 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
690 lprintf("%39s", "");
692 break;
694 case '\33':
695 return;
697 cursor(40, 17);
698 lprintf("%8ld", (long) c[BANKACCOUNT]);
699 cursor(49, 18);
700 lprintf("%8ld", (long) c[GOLD]);
704 #if 0 /* XXX: apparently unused */
706 subroutine to appraise any stone for the bank
708 static void
709 appraise(int gemstone)
711 int j, amt;
712 for (j = 0; j < 26; j++)
713 if (iven[j] == gemstone) {
714 lprintf("\nI see you have %s", objectname[gemstone]);
715 if (gemstone == OLARNEYE)
716 lprcat(" I must commend you. I didn't think\nyou could get it.");
717 lprcat(" Shall I appraise it for you? ");
718 yrepcount = 0;
719 if (getyn() == 'y') {
720 lprcat("yes.\n Just one moment please \n");
721 nap(1000);
722 if (gemstone == OLARNEYE) {
723 amt = 250000 - ((gltime * 7) / 100) * 100;
724 if (amt < 50000)
725 amt = 50000;
726 } else
727 amt = (255 & ivenarg[j]) * 100;
728 lprintf("\nI can see this is an excellent stone, It is worth %ld", (long) amt);
729 lprcat("\nWould you like to sell it to us? ");
730 yrepcount = 0;
731 if (getyn() == 'y') {
732 lprcat("yes\n");
733 c[GOLD] += amt;
734 iven[j] = 0;
735 } else
736 lprcat("no thank you.\n");
737 if (gemstone == OLARNEYE)
738 lprcat("It is, of course, your privilege to keep the stone\n");
739 } else
740 lprcat("no\nO. K.\n");
743 #endif /* 0 - unused */
746 function for the trading post
748 static void
749 otradhead()
751 clear();
752 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n");
753 lprcat("useful. Since the condition of the items you bring in is not certain,\n");
754 lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
755 lprcat("only 20% of their value were they to be new. If the items are badly\n");
756 lprcat("damaged, we will pay only 10% of their new value.\n\n");
759 void
760 otradepost()
762 int i, j, value, isub, izarg;
763 dnditm = dndcount = 0;
764 nosignal = 1; /* disable signals */
765 resetscroll();
766 otradhead();
767 while (1) {
768 lprcat("\nWhat item do you want to sell to us [");
769 standout("*");
770 lprcat(" for list, or ");
771 standout("escape");
772 lprcat("] ? ");
773 i = 0;
774 while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.'))
775 i = ttgetch();
776 if (i == '\33') {
777 setscroll();
778 recalc();
779 drawscreen();
780 nosignal = 0; /* enable signals */
781 return;
783 isub = i - 'a';
784 j = 0;
785 if (iven[isub] == OSCROLL)
786 if (scrollname[ivenarg[isub]][0] == 0) {
787 j = 1;
788 cnsitm();
789 } /* can't sell unidentified item */
790 if (iven[isub] == OPOTION)
791 if (potionname[ivenarg[isub]][0] == 0) {
792 j = 1;
793 cnsitm();
794 } /* can't sell unidentified item */
795 if (!j) {
796 if (i == '*') {
797 clear();
798 qshowstr();
799 otradhead();
800 } else if (iven[isub] == 0)
801 lprintf("\nYou don't have item %c!", isub + 'a');
802 else {
803 for (j = 0; j < MAXITM; j++)
804 if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) {
805 srcount = 0;
806 show3(isub); /* show what the item
807 * was */
808 if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
809 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
810 value = 20 * ivenarg[isub];
811 else if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION))
812 value = 2 * itm[j + ivenarg[isub]].price;
813 else {
814 izarg = ivenarg[isub];
815 value = itm[j].price; /* appreciate if a +n
816 * object */
817 if (izarg >= 0)
818 value *= 2;
819 while ((izarg-- > 0) && ((value = 14 * (67 + value) / 10) < 500000));
821 lprintf("\nItem (%c) is worth %ld gold pieces to us. Do you want to sell it? ", i, (long) value);
822 yrepcount = 0;
823 if (getyn() == 'y') {
824 lprcat("yes\n");
825 c[GOLD] += value;
826 if (c[WEAR] == isub)
827 c[WEAR] = -1;
828 if (c[WIELD] == isub)
829 c[WIELD] = -1;
830 if (c[SHIELD] == isub)
831 c[SHIELD] = -1;
832 adjustcvalues(iven[isub], ivenarg[isub]);
833 iven[isub] = 0;
834 } else
835 lprcat("no thanks.\n");
836 j = MAXITM + 100; /* get out of the inner
837 * loop */
839 if (j <= MAXITM + 2)
840 lprcat("\nSo sorry, but we are not authorized to accept that item.");
846 static void
847 cnsitm(void)
849 lprcat("\nSorry, we can't accept unidentified objects.");
853 * for the Larn Revenue Service
855 void
856 olrs()
858 int i, first;
859 long amt;
860 first = nosignal = 1; /* disable signals */
861 clear();
862 resetscroll();
863 cursor(1, 4);
864 lprcat("Welcome to the Larn Revenue Service district office. How can we help you?");
865 while (1) {
866 if (first) {
867 first = 0;
868 goto nxt;
870 cursors();
871 lprcat("\n\nYour wish? [(");
872 standout("p");
873 lprcat(") pay taxes, or ");
874 standout("escape");
875 lprcat("] ");
876 yrepcount = 0;
877 i = 0;
878 while (i != 'p' && i != '\33')
879 i = ttgetch();
880 switch (i) {
881 case 'p':
882 lprcat("pay taxes\nHow much? ");
883 amt = readnum((long) c[GOLD]);
884 if (amt < 0) {
885 lprcat("\nSorry, but we can't take negative gold\n");
886 amt = 0;
887 } else if (amt > c[GOLD])
888 lprcat(" You don't have that much.\n");
889 else
890 c[GOLD] -= paytaxes(amt);
891 break;
893 case '\33':
894 nosignal = 0; /* enable signals */
895 setscroll();
896 drawscreen();
897 return;
900 nxt: cursor(1, 6);
901 if (outstanding_taxes > 0)
902 lprintf("You presently owe %ld gp in taxes. ", (long) outstanding_taxes);
903 else
904 lprcat("You do not owe us any taxes. ");
905 cursor(1, 8);
906 if (c[GOLD] > 0)
907 lprintf("You have %6ld gp. ", (long) c[GOLD]);
908 else
909 lprcat("You have no gold pieces. ");