bsd-family-tree: Small sync with FreeBSD.
[dragonfly.git] / games / larn / store.c
blob6867ef0ef551875e04e451848cea008413ad31c5
1 /*-
2 * Copyright (c) 1988 The Regents of the University of California.
3 * All rights reserved.
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. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
29 * @(#)store.c 5.4 (Berkeley) 5/13/91
30 * $FreeBSD: src/games/larn/store.c,v 1.5 1999/11/30 03:49:00 billf Exp $
31 * $DragonFly: src/games/larn/store.c,v 1.4 2006/08/26 17:05:05 pavalos Exp $
34 /* store.c Larn is copyrighted 1986 by Noah Morgan. */
35 #include "header.h"
37 static void dnd_2hed(void);
38 static void dnd_hed(void);
39 static void handsfull(void);
40 static void outofstock(void);
41 static void nogold(void);
42 static void dnditem(int);
43 static void sch_hed(void);
44 static void banktitle(const char *);
45 static void obanksub(void);
46 static void otradhead(void);
47 static void cnsitm(void);
49 static int dndcount = 0, dnditm = 0;
51 /* this is the data for the stuff in the dnd store */
52 int maxitm = 83; /* number of items in the dnd inventory table */
53 struct _itm itm_[90] = {
54 /*cost iven name iven arg how
55 gp iven[] ivenarg[] many */
57 { 2, OLEATHER, 0, 3 },
58 { 10, OSTUDLEATHER, 0, 2 },
59 { 40, ORING, 0, 2 },
60 { 85, OCHAIN, 0, 2 },
61 { 220, OSPLINT, 0, 1 },
62 { 400, OPLATE, 0, 1 },
63 { 900, OPLATEARMOR, 0, 1 },
64 { 2600, OSSPLATE, 0, 1 },
65 { 150, OSHIELD, 0, 1 },
67 /*cost iven name iven arg how
68 gp iven[] ivenarg[] many */
70 { 2, ODAGGER, 0, 3 },
71 { 20, OSPEAR, 0, 3 },
72 { 80, OFLAIL, 0, 2 },
73 { 150, OBATTLEAXE, 0, 2 },
74 { 450, OLONGSWORD, 0, 2 },
75 { 1000, O2SWORD, 0, 2 },
76 { 5000, OSWORD, 0, 1 },
77 { 16500, OLANCE, 0, 1 },
78 { 6000, OSWORDofSLASHING, 0, 0 },
79 { 10000, OHAMMER, 0, 0 },
81 /*cost iven name iven arg how
82 gp iven[] ivenarg[] many */
84 { 150, OPROTRING, 1, 1 },
85 { 85, OSTRRING, 1, 1 },
86 { 120, ODEXRING, 1, 1 },
87 { 120, OCLEVERRING, 1, 1 },
88 { 180, OENERGYRING, 0, 1 },
89 { 125, ODAMRING, 0, 1 },
90 { 220, OREGENRING, 0, 1 },
91 { 1000, ORINGOFEXTRA, 0, 1 },
93 { 280, OBELT, 0, 1 },
95 { 400, OAMULET, 0, 1 },
97 { 6500, OORBOFDRAGON, 0, 0 },
98 { 5500, OSPIRITSCARAB, 0, 0 },
99 { 5000, OCUBEofUNDEAD, 0, 0 },
100 { 6000, ONOTHEFT, 0, 0 },
102 { 590, OCHEST, 6, 1 },
103 { 200, OBOOK, 8, 1 },
104 { 10, OCOOKIE, 0, 3 },
106 /*cost iven name iven arg how
107 gp iven[] ivenarg[] many */
109 { 20, OPOTION, 0, 6 },
110 { 90, OPOTION, 1, 5 },
111 { 520, OPOTION, 2, 1 },
112 { 100, OPOTION, 3, 2 },
113 { 50, OPOTION, 4, 2 },
114 { 150, OPOTION, 5, 2 },
115 { 70, OPOTION, 6, 1 },
116 { 30, OPOTION, 7, 7 },
117 { 200, OPOTION, 8, 1 },
118 { 50, OPOTION, 9, 1 },
119 { 80, OPOTION, 10, 1 },
121 /*cost iven name iven arg how
122 gp iven[] ivenarg[] many */
124 { 30, OPOTION, 11, 3 },
125 { 20, OPOTION, 12, 5 },
126 { 40, OPOTION, 13, 3 },
127 { 35, OPOTION, 14, 2 },
128 { 520, OPOTION, 15, 1 },
129 { 90, OPOTION, 16, 2 },
130 { 200, OPOTION, 17, 2 },
131 { 220, OPOTION, 18, 4 },
132 { 80, OPOTION, 19, 6 },
133 { 370, OPOTION, 20, 3 },
134 { 50, OPOTION, 22, 1 },
135 { 150, OPOTION, 23, 3 },
137 /*cost iven name iven arg how
138 gp iven[] ivenarg[] many */
140 { 100, OSCROLL, 0, 2 },
141 { 125, OSCROLL, 1, 2 },
142 { 60, OSCROLL, 2, 4 },
143 { 10, OSCROLL, 3, 4 },
144 { 100, OSCROLL, 4, 3 },
145 { 200, OSCROLL, 5, 2 },
146 { 110, OSCROLL, 6, 1 },
147 { 500, OSCROLL, 7, 2 },
148 { 200, OSCROLL, 8, 2 },
149 { 250, OSCROLL, 9, 4 },
150 { 20, OSCROLL, 10, 5 },
151 { 30, OSCROLL, 11, 3 },
153 /*cost iven name iven arg how
154 gp iven[] ivenarg[] many */
156 { 340, OSCROLL, 12, 1 },
157 { 340, OSCROLL, 13, 1 },
158 { 300, OSCROLL, 14, 2 },
159 { 400, OSCROLL, 15, 2 },
160 { 500, OSCROLL, 16, 2 },
161 { 1000, OSCROLL, 17, 1 },
162 { 500, OSCROLL, 18, 1 },
163 { 340, OSCROLL, 19, 2 },
164 { 220, OSCROLL, 20, 3 },
165 { 3900, OSCROLL, 21, 0 },
166 { 610, OSCROLL, 22, 1 },
167 { 3000, OSCROLL, 23, 0 }
171 function for the dnd store
173 static void
174 dnd_2hed(void)
176 lprcat("Welcome to the Larn Thrift Shoppe. We stock many items explorers find useful\n");
177 lprcat(" in their adventures. Feel free to browse to your hearts content.\n");
178 lprcat("Also be advised, if you break 'em, you pay for 'em.");
181 static void
182 dnd_hed(void)
184 int i;
185 for (i = dnditm; i < 26 + dnditm; i++)
186 dnditem(i);
187 cursor(50, 18);
188 lprcat("You have ");
191 static void
192 handsfull(void)
194 lprcat("\nYou can't carry anything more!");
195 lflush();
196 nap(2200);
199 static void
200 outofstock(void)
202 lprcat("\nSorry, but we are out of that item.");
203 lflush();
204 nap(2200);
207 static void
208 nogold(void)
210 lprcat("\nYou don't have enough gold to pay for that!");
211 lflush();
212 nap(2200);
215 void
216 dndstore(void)
218 int i;
219 dnditm = 0;
220 nosignal = 1; /* disable signals */
221 clear();
222 dnd_2hed();
223 if (outstanding_taxes > 0) {
224 lprcat("\n\nThe Larn Revenue Service has ordered us to not do business with tax evaders.\n");
225 beep();
226 lprintf("They have also told us that you owe %d gp in back taxes, and as we must\n", (long)outstanding_taxes);
227 lprcat("comply with the law, we cannot serve you at this time. Soo Sorry.\n");
228 cursors();
229 lprcat("\nPress ");
230 standout("escape");
231 lprcat(" to leave: ");
232 lflush();
233 i = 0;
234 while (i != '\33')
235 i = getchr();
236 drawscreen();
237 nosignal = 0; /* enable signals */
238 return;
241 dnd_hed();
242 while (1) {
243 cursor(59, 18);
244 lprintf("%d gold pieces", (long)c[GOLD]);
245 cltoeoln();
246 cl_dn(1, 20); /* erase to eod */
247 lprcat("\nEnter your transaction [");
248 standout("space");
249 lprcat(" for more, ");
250 standout("escape");
251 lprcat(" to leave]? ");
252 i = 0;
253 while ((i < 'a' || i > 'z') && (i != ' ') && (i != '\33') && (i != 12))
254 i = getchr();
255 if (i == 12) {
256 clear();
257 dnd_2hed();
258 dnd_hed();
259 } else if (i == '\33') {
260 drawscreen();
261 nosignal = 0; /* enable signals */
262 return;
263 } else if (i == ' ') {
264 cl_dn(1, 4);
265 if ((dnditm += 26) >= maxitm)
266 dnditm = 0;
267 dnd_hed();
268 } else { /* buy something */
269 lprc(i);/* echo the byte */
270 i += dnditm - 'a';
271 if (i >= maxitm)
272 outofstock();
273 else if (itm_[i].qty <= 0)
274 outofstock();
275 else if (pocketfull())
276 handsfull();
277 else if (c[GOLD] < itm_[i].price * 10)
278 nogold();
279 else {
280 if (itm_[i].obj == OPOTION)
281 potionname[itm_[i].arg] = potionhide[itm_[i].arg];
282 else if (itm_[i].obj == OSCROLL)
283 scrollname[itm_[i].arg] = scrollhide[itm_[i].arg];
284 c[GOLD] -= itm_[i].price * 10;
285 itm_[i].qty--;
286 take(itm_[i].obj, itm_[i].arg);
287 if (itm_[i].qty == 0)
288 dnditem(i);
289 nap(1001);
296 dnditem(index)
298 to print the item list; used in dndstore() enter with the index into itm_
300 static void
301 dnditem(int i)
303 int j, k;
304 if (i >= maxitm)
305 return;
306 cursor((j = (i & 1) * 40 + 1), (k = ((i % 26) >> 1) + 5));
307 if (itm_[i].qty == 0) {
308 lprintf("%39s", "");
309 return;
311 lprintf("%c) ", (i % 26) + 'a');
312 if (itm_[i].obj == OPOTION) {
313 lprcat("potion of ");
314 lprintf("%s", potionhide[itm_[i].arg]);
315 } else if (itm_[i].obj == OSCROLL) {
316 lprcat("scroll of ");
317 lprintf("%s", scrollhide[itm_[i].arg]);
318 } else
319 lprintf("%s", objectname[itm_[i].obj]);
320 cursor(j + 31, k);
321 lprintf("%6d", (long)(itm_[i].price * 10));
325 for the college of larn
327 char course[26] = { 0 }; /* the list of courses taken */
328 char coursetime[] = { 10, 15, 10, 20, 10, 10, 10, 5 };
330 function to display the header info for the school
332 static void
333 sch_hed(void)
335 clear();
336 lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
337 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n");
338 lprcat("\t\t Course Name \t Time Needed\n\n");
340 if (course[0] == 0)
341 lprcat("\t\ta) Fighters Training I 10 mobuls"); /* line 7 of crt */
342 lprc('\n');
343 if (course[1] == 0)
344 lprcat("\t\tb) Fighters Training II 15 mobuls");
345 lprc('\n');
346 if (course[2] == 0)
347 lprcat("\t\tc) Introduction to Wizardry 10 mobuls");
348 lprc('\n');
349 if (course[3] == 0)
350 lprcat("\t\td) Applied Wizardry 20 mobuls");
351 lprc('\n');
352 if (course[4] == 0)
353 lprcat("\t\te) Behavioral Psychology 10 mobuls");
354 lprc('\n');
355 if (course[5] == 0)
356 lprcat("\t\tf) Faith for Today 10 mobuls");
357 lprc('\n');
358 if (course[6] == 0)
359 lprcat("\t\tg) Contemporary Dance 10 mobuls");
360 lprc('\n');
361 if (course[7] == 0)
362 lprcat("\t\th) History of Larn 5 mobuls");
364 lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
365 cursor(30, 18);
366 lprcat("You are presently carrying ");
369 void
370 oschool(void)
372 int i;
373 long time_used;
374 nosignal = 1; /* disable signals */
375 sch_hed();
376 while (1) {
377 cursor(57, 18);
378 lprintf("%d gold pieces. ", (long)c[GOLD]);
379 cursors();
380 lprcat("\nWhat is your choice [");
381 standout("escape");
382 lprcat(" to leave] ? ");
383 yrepcount = 0;
384 i = 0;
385 while ((i < 'a' || i > 'h') && (i != '\33') && (i != 12))
386 i = getchr();
387 if (i == 12) {
388 sch_hed();
389 continue;
390 } else if (i == '\33') {
391 nosignal = 0;
392 drawscreen(); /* enable signals */
393 return;
395 lprc(i);
396 if (c[GOLD] < 250)
397 nogold();
398 else if (course[i - 'a']) {
399 lprcat("\nSorry, but that class is filled.");
400 nap(1000);
401 } else if (i <= 'h') {
402 c[GOLD] -= 250;
403 time_used = 0;
404 switch (i) {
405 case 'a':
406 c[STRENGTH] += 2;
407 c[CONSTITUTION]++;
408 lprcat("\nYou feel stronger!");
409 cl_line(16, 7);
410 break;
412 case 'b':
413 if (course[0] == 0) {
414 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
415 c[GOLD] += 250;
416 time_used = -10000;
417 break;
419 lprcat("\nYou feel much stronger!");
420 cl_line(16, 8);
421 c[STRENGTH] += 2;
422 c[CONSTITUTION] += 2;
423 break;
425 case 'c':
426 c[INTELLIGENCE] += 2;
427 lprcat("\nThe task before you now seems more attainable!");
428 cl_line(16, 9);
429 break;
431 case 'd':
432 if (course[2] == 0) {
433 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
434 c[GOLD] += 250;
435 time_used = -10000;
436 break;
438 lprcat("\nThe task before you now seems very attainable!");
439 cl_line(16, 10);
440 c[INTELLIGENCE] += 2;
441 break;
443 case 'e':
444 c[CHARISMA] += 3;
445 lprcat("\nYou now feel like a born leader!");
446 cl_line(16, 11);
447 break;
449 case 'f':
450 c[WISDOM] += 2;
451 lprcat("\nYou now feel more confident that you can find the potion in time!");
452 cl_line(16, 12);
453 break;
455 case 'g':
456 c[DEXTERITY] += 3;
457 lprcat("\nYou feel like dancing!");
458 cl_line(16, 13);
459 break;
461 case 'h':
462 c[INTELLIGENCE]++;
463 lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
464 lprcat("by a platinum dragon who possesses psionic abilities. ");
465 cl_line(16, 14);
466 break;
468 time_used += coursetime[i - 'a'] * 100;
469 if (time_used > 0) {
470 gtime += time_used;
471 course[i - 'a']++; /* remember that he has taken that course */
472 c[HP] = c[HPMAX];
473 c[SPELLS] = c[SPELLMAX]; /* he regenerated */
475 if (c[BLINDCOUNT])
476 c[BLINDCOUNT] = 1; /* cure blindness too! */
477 if (c[CONFUSE])
478 c[CONFUSE] = 1; /* end confusion */
479 larn_adjtime((long)time_used); /* adjust parameters for time change */
481 nap(1000);
487 * for the first national bank of Larn
489 int lasttime = 0; /* last time he was in bank */
491 void
492 obank(void)
494 banktitle(" Welcome to the First National Bank of Larn.");
497 void
498 obank2(void)
500 banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
503 static void
504 banktitle(const char *str)
506 nosignal = 1; /* disable signals */
507 clear();
508 lprcat(str);
509 if (outstanding_taxes > 0) {
510 int i;
511 lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n");
512 beep();
513 lprintf("levied taxes have been paid. They have also told us that you owe %d gp in\n", (long)outstanding_taxes);
514 lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n");
515 lprcat("We suggest you go to the LRS office and pay your taxes.\n");
516 cursors();
517 lprcat("\nPress ");
518 standout("escape");
519 lprcat(" to leave: ");
520 lflush();
521 i = 0;
522 while (i != '\33')
523 i = getchr();
524 drawscreen();
525 nosignal = 0; /* enable signals */
526 return;
528 lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
529 obanksub();
530 nosignal = 0; /* enable signals */
531 drawscreen();
535 * function to put interest on your bank account
537 void
538 ointerest(void)
540 int i;
541 if (c[BANKACCOUNT] < 0)
542 c[BANKACCOUNT] = 0;
543 else if ((c[BANKACCOUNT] > 0) && (c[BANKACCOUNT] < 500000)) {
544 i = (gtime - lasttime) / 100; /* # mobuls elapsed */
545 while ((i-- > 0) && (c[BANKACCOUNT] < 500000))
546 c[BANKACCOUNT] += c[BANKACCOUNT] / 250;
547 if (c[BANKACCOUNT] > 500000)
548 c[BANKACCOUNT] = 500000; /* interest limit */
550 lasttime = (gtime / 100) * 100;
553 static short gemorder[26] = { 0 }; /* the reference to screen location for each */
554 static long gemvalue[26] = { 0 }; /* the appraisal of the gems */
556 static void
557 obanksub(void)
559 unsigned long amt;
560 int i, k;
561 ointerest(); /* credit any needed interest */
563 for (k = i = 0; i < 26; i++)
564 switch (iven[i]) {
565 case OLARNEYE:
566 case ODIAMOND:
567 case OEMERALD:
568 case ORUBY:
569 case OSAPPHIRE:
571 if (iven[i] == OLARNEYE) {
572 gemvalue[i] = 250000 - ((gtime * 7) / 100) * 100;
573 if (gemvalue[i] < 50000)
574 gemvalue[i] = 50000;
575 } else
576 gemvalue[i] = (255 & ivenarg[i]) * 100;
577 gemorder[i] = k;
578 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
579 lprintf("%c) %s", i + 'a', objectname[(int)iven[i]]);
580 cursor((k % 2) * 40 + 33, (k >> 1) + 4);
581 lprintf("%5d", (long)gemvalue[i]);
582 k++;
584 cursor(31, 17);
585 lprintf("You have %8d gold pieces in the bank.", (long)c[BANKACCOUNT]);
586 cursor(40, 18);
587 lprintf("You have %8d gold pieces", (long)c[GOLD]);
588 if (c[BANKACCOUNT] + c[GOLD] >= 500000)
589 lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest.");
590 while (1) {
591 cl_dn(1, 20);
592 lprcat("\nYour wish? [(");
593 standout("d");
594 lprcat(") deposit, (");
595 standout("w");
596 lprcat(") withdraw, (");
597 standout("s");
598 lprcat(") sell a stone, or ");
599 standout("escape");
600 lprcat("] ");
601 yrepcount = 0;
602 i = 0;
603 while (i != 'd' && i != 'w' && i != 's' && i != '\33')
604 i = getchr();
605 switch (i) {
606 case 'd':
607 lprcat("deposit\nHow much? ");
608 amt = readnum((long)c[GOLD]);
609 if (amt > (unsigned)c[GOLD]) {
610 lprcat(" You don't have that much.");
611 nap(2000);
612 } else {
613 c[GOLD] -= amt;
614 c[BANKACCOUNT] += amt;
616 break;
618 case 'w':
619 lprcat("withdraw\nHow much? ");
620 amt = readnum((long)c[BANKACCOUNT]);
621 if (amt > (unsigned)c[BANKACCOUNT]) {
622 lprcat("\nYou don't have that much in the bank!");
623 nap(2000);
624 } else {
625 c[GOLD] += amt;
626 c[BANKACCOUNT] -= amt;
628 break;
630 case 's':
631 lprcat("\nWhich stone would you like to sell? ");
632 i = 0;
633 while ((i < 'a' || i > 'z') && i != '*')
634 i = getchr();
635 if (i == '*')
636 for (i = 0; i < 26; i++) {
637 if (gemvalue[i]) {
638 c[GOLD] += gemvalue[i];
639 iven[i] = 0;
640 gemvalue[i] = 0;
641 k = gemorder[i];
642 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
643 lprintf("%39s", "");
646 else {
647 if (gemvalue[i = i - 'a'] == 0) {
648 lprintf("\nItem %c is not a gemstone!", i + 'a');
649 nap(2000);
650 break;
652 c[GOLD] += gemvalue[i];
653 iven[i] = 0;
654 gemvalue[i] = 0;
655 k = gemorder[i];
656 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
657 lprintf("%39s", "");
659 break;
661 case '\33':
662 return;
664 cursor(40, 17);
665 lprintf("%8d", (long)c[BANKACCOUNT]);
666 cursor(49, 18);
667 lprintf("%8d", (long)c[GOLD]);
671 function for the trading post
673 static void
674 otradhead(void)
676 clear();
677 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n");
678 lprcat("useful. Since the condition of the items you bring in is not certain,\n");
679 lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
680 lprcat("only 20% of their value were they to be new. If the items are badly\n");
681 lprcat("damaged, we will pay only 10% of their new value.\n\n");
684 void
685 otradepost(void)
687 int i, j, value, isub, izarg;
688 dnditm = dndcount = 0;
689 nosignal = 1; /* disable signals */
690 resetscroll();
691 otradhead();
692 while (1) {
693 lprcat("\nWhat item do you want to sell to us [");
694 standout("*");
695 lprcat(" for list, or ");
696 standout("escape");
697 lprcat("] ? ");
698 i = 0;
699 while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.')) i = getchr();
700 if (i == '\33') {
701 setscroll();
702 recalc();
703 drawscreen();
704 nosignal = 0; /* enable signals */
705 return;
707 isub = i - 'a';
708 j = 0;
709 if (iven[isub] == OSCROLL)
710 if (scrollname[ivenarg[isub]][0] == 0) {
711 j = 1;
712 cnsitm();
713 } /* can't sell unidentified item */
714 if (iven[isub] == OPOTION)
715 if (potionname[ivenarg[isub]][0] == 0) {
716 j = 1;
717 cnsitm();
718 } /* can't sell unidentified item */
719 if (!j) {
720 if (i == '*') {
721 clear();
722 qshowstr();
723 otradhead();
724 } else if (iven[isub] == 0)
725 lprintf("\nYou don't have item %c!", isub + 'a');
726 else {
727 for (j = 0; j < maxitm; j++)
728 if ((itm_[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) {
729 srcount = 0;
730 show3(isub); /* show what the item was */
731 if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
732 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
733 value = 20 * ivenarg[isub];
734 else if ((itm_[j].obj == OSCROLL) || (itm_[j].obj == OPOTION)) value = 2 * itm_[j + ivenarg[isub]].price;
735 else {
736 izarg = ivenarg[isub];
737 value = itm_[j].price; /* appreciate if a +n object */
738 if (izarg >= 0)
739 value *= 2;
740 while ((izarg-- > 0) && ((value = 14 * (67 + value) / 10) < 500000))
743 lprintf("\nItem (%c) is worth %d gold pieces to us. Do you want to sell it? ", i, (long)value);
744 yrepcount = 0;
745 if (getyn() == 'y') {
746 lprcat("yes\n");
747 c[GOLD] += value;
748 if (c[WEAR] == isub)
749 c[WEAR] = -1;
750 if (c[WIELD] == isub)
751 c[WIELD] = -1;
752 if (c[SHIELD] == isub)
753 c[SHIELD] = -1;
754 adjustcvalues(iven[isub], ivenarg[isub]);
755 iven[isub] = 0;
756 } else
757 lprcat("no thanks.\n");
758 j = maxitm + 100; /* get out of the inner loop */
760 if (j <= maxitm + 2)
761 lprcat("\nSo sorry, but we are not authorized to accept that item.");
767 static void
768 cnsitm(void)
770 lprcat("\nSorry, we can't accept unidentified objects.");
774 * for the Larn Revenue Service
776 void
777 olrs(void)
779 int i, first;
780 unsigned long amt;
781 first = nosignal = 1; /* disable signals */
782 clear();
783 resetscroll();
784 cursor(1, 4);
785 lprcat("Welcome to the Larn Revenue Service district office. How can we help you?");
786 while (1) {
787 if (first) {
788 first = 0;
789 goto nxt;
791 cursors();
792 lprcat("\n\nYour wish? [(");
793 standout("p");
794 lprcat(") pay taxes, or ");
795 standout("escape");
796 lprcat("] ");
797 yrepcount = 0;
798 i = 0;
799 while (i != 'p' && i != '\33')
800 i = getchr();
801 switch (i) {
802 case 'p':
803 lprcat("pay taxes\nHow much? ");
804 amt = readnum((long)c[GOLD]);
805 if (amt > (unsigned)c[GOLD])
806 lprcat(" You don't have that much.\n");
807 else
808 c[GOLD] -= paytaxes((long)amt);
809 break;
811 case '\33':
812 nosignal = 0; /* enable signals */
813 setscroll();
814 drawscreen();
815 return;
818 nxt: cursor(1, 6);
819 if (outstanding_taxes > 0)
820 lprintf("You presently owe %d gp in taxes. ", (long)outstanding_taxes);
821 else
822 lprcat("You do not owe us any taxes. ");
823 cursor(1, 8);
824 if (c[GOLD] > 0)
825 lprintf("You have %6d gp. ", (long)c[GOLD]);
826 else
827 lprcat("You have no gold pieces. ");