]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/store.c
Reset CVS keywords
[bsdgames-darwin.git] / larn / store.c
1 /* $NetBSD: store.c,v 1.16 2012/06/19 05:30:44 dholland 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. 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.
18 *
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.
30 */
31
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.16 2012/06/19 05:30:44 dholland Exp $");
38 #endif
39 #endif /* not lint */
40
41 /* store.c Larn is copyrighted 1986 by Noah Morgan. */
42 #include "header.h"
43 #include "extern.h"
44
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);
53
54 static int dndcount = 0, dnditm = 0;
55
56 /* number of items in the dnd inventory table */
57 #define MAXITM 83
58
59 /* this is the data for the stuff in the dnd store */
60 struct _itm itm[90] = {
61 /*
62 * cost iven name iven arg how gp
63 * iven[] ivenarg[] many
64 */
65
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},
75
76 /*
77 * cost iven name iven arg how gp
78 * iven[] ivenarg[] many
79 */
80
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},
91
92 /*
93 * cost iven name iven arg how gp
94 * iven[] ivenarg[] many
95 */
96
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},
105
106 {280, OBELT, 0, 1},
107
108 {400, OAMULET, 0, 1},
109
110 {6500, OORBOFDRAGON, 0, 0},
111 {5500, OSPIRITSCARAB, 0, 0},
112 {5000, OCUBEofUNDEAD, 0, 0},
113 {6000, ONOTHEFT, 0, 0},
114
115 {590, OCHEST, 6, 1},
116 {200, OBOOK, 8, 1},
117 {10, OCOOKIE, 0, 3},
118
119 /*
120 * cost iven name iven arg how gp
121 * iven[] ivenarg[] many
122 */
123
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},
135
136 /*
137 * cost iven name iven arg how gp
138 * iven[] ivenarg[] many
139 */
140
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},
153
154 /*
155 * cost iven name iven arg how gp
156 * iven[] ivenarg[] many
157 */
158
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},
171
172 /*
173 * cost iven name iven arg how gp
174 * iven[] ivenarg[] many
175 */
176
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}
189 };
190
191 /*
192 function for the dnd store
193 */
194 static void
195 dnd_2hed(void)
196 {
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.");
200 }
201
202 static void
203 dnd_hed(void)
204 {
205 int i;
206 for (i = dnditm; i < 26 + dnditm; i++)
207 dnditem(i);
208 cursor(50, 18);
209 lprcat("You have ");
210 }
211
212 static void
213 handsfull(void)
214 {
215 lprcat("\nYou can't carry anything more!");
216 lflush();
217 nap(2200);
218 }
219
220 static void
221 outofstock(void)
222 {
223 lprcat("\nSorry, but we are out of that item.");
224 lflush();
225 nap(2200);
226 }
227
228 static void
229 nogold(void)
230 {
231 lprcat("\nYou don't have enough gold to pay for that!");
232 lflush();
233 nap(2200);
234 }
235
236 void
237 dndstore(void)
238 {
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;
260 }
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];
304 }
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);
311 }
312 }
313
314 }
315 }
316
317 /*
318 dnditem(index)
319
320 to print the item list; used in dndstore() enter with the index into itm
321 */
322 static void
323 dnditem(int i)
324 {
325 int j, k;
326 if (i >= MAXITM)
327 return;
328 cursor((j = (i & 1) * 40 + 1), (k = ((i % 26) >> 1) + 5));
329 if (itm[i].qty == 0) {
330 lprintf("%39s", "");
331 return;
332 }
333 lprintf("%c) ", (i % 26) + 'a');
334 if (itm[i].obj == OPOTION) {
335 lprintf("potion of%s", potionhide[itm[i].arg]);
336 } else if (itm[i].obj == OSCROLL) {
337 lprintf("scroll of%s", scrollhide[itm[i].arg]);
338 } else
339 lprintf("%s", objectname[itm[i].obj]);
340 cursor(j + 31, k);
341 lprintf("%6ld", (long) (itm[i].price * 10));
342 }
343
344
345
346 /*
347 for the college of larn
348 */
349 u_char course[26] = {0}; /* the list of courses taken */
350 static char coursetime[] = {10, 15, 10, 20, 10, 10, 10, 5};
351 /*
352 function to display the header info for the school
353 */
354 static void
355 sch_hed(void)
356 {
357 clear();
358 lprcat("The College of Larn offers the exciting opportunity of higher education to\n");
359 lprcat("all inhabitants of the caves. Here is a list of the class schedule:\n\n\n");
360 lprcat("\t\t Course Name \t Time Needed\n\n");
361
362 if (course[0] == 0)
363 lprcat("\t\ta) Fighters Training I 10 mobuls"); /* line 7 of crt */
364 lprc('\n');
365 if (course[1] == 0)
366 lprcat("\t\tb) Fighters Training II 15 mobuls");
367 lprc('\n');
368 if (course[2] == 0)
369 lprcat("\t\tc) Introduction to Wizardry 10 mobuls");
370 lprc('\n');
371 if (course[3] == 0)
372 lprcat("\t\td) Applied Wizardry 20 mobuls");
373 lprc('\n');
374 if (course[4] == 0)
375 lprcat("\t\te) Behavioral Psychology 10 mobuls");
376 lprc('\n');
377 if (course[5] == 0)
378 lprcat("\t\tf) Faith for Today 10 mobuls");
379 lprc('\n');
380 if (course[6] == 0)
381 lprcat("\t\tg) Contemporary Dance 10 mobuls");
382 lprc('\n');
383 if (course[7] == 0)
384 lprcat("\t\th) History of Larn 5 mobuls");
385
386 lprcat("\n\n\t\tAll courses cost 250 gold pieces.");
387 cursor(30, 18);
388 lprcat("You are presently carrying ");
389 }
390
391 void
392 oschool(void)
393 {
394 int i;
395 long time_used;
396 nosignal = 1; /* disable signals */
397 sch_hed();
398 while (1) {
399 cursor(57, 18);
400 lprintf("%ld gold pieces. ", (long) c[GOLD]);
401 cursors();
402 lprcat("\nWhat is your choice [");
403 standout("escape");
404 lprcat(" to leave] ? ");
405 yrepcount = 0;
406 i = 0;
407 while ((i < 'a' || i > 'h') && (i != '\33') && (i != 12))
408 i = ttgetch();
409 if (i == 12) {
410 sch_hed();
411 continue;
412 } else if (i == '\33') {
413 nosignal = 0;
414 drawscreen(); /* enable signals */
415 return;
416 }
417 lprc(i);
418 if (c[GOLD] < 250)
419 nogold();
420 else if (course[i - 'a']) {
421 lprcat("\nSorry, but that class is filled.");
422 nap(1000);
423 } else if (i <= 'h') {
424 c[GOLD] -= 250;
425 time_used = 0;
426 switch (i) {
427 case 'a':
428 c[STRENGTH] += 2;
429 c[CONSTITUTION]++;
430 lprcat("\nYou feel stronger!");
431 cl_line(16, 7);
432 break;
433
434 case 'b':
435 if (course[0] == 0) {
436 lprcat("\nSorry, but this class has a prerequisite of Fighters Training I");
437 c[GOLD] += 250;
438 time_used = -10000;
439 break;
440 }
441 lprcat("\nYou feel much stronger!");
442 cl_line(16, 8);
443 c[STRENGTH] += 2;
444 c[CONSTITUTION] += 2;
445 break;
446
447 case 'c':
448 c[INTELLIGENCE] += 2;
449 lprcat("\nThe task before you now seems more attainable!");
450 cl_line(16, 9);
451 break;
452
453 case 'd':
454 if (course[2] == 0) {
455 lprcat("\nSorry, but this class has a prerequisite of Introduction to Wizardry");
456 c[GOLD] += 250;
457 time_used = -10000;
458 break;
459 }
460 lprcat("\nThe task before you now seems very attainable!");
461 cl_line(16, 10);
462 c[INTELLIGENCE] += 2;
463 break;
464
465 case 'e':
466 c[CHARISMA] += 3;
467 lprcat("\nYou now feel like a born leader!");
468 cl_line(16, 11);
469 break;
470
471 case 'f':
472 c[WISDOM] += 2;
473 lprcat("\nYou now feel more confident that you can find the potion in time!");
474 cl_line(16, 12);
475 break;
476
477 case 'g':
478 c[DEXTERITY] += 3;
479 lprcat("\nYou feel like dancing!");
480 cl_line(16, 13);
481 break;
482
483 case 'h':
484 c[INTELLIGENCE]++;
485 lprcat("\nYour instructor told you that the Eye of Larn is rumored to be guarded\n");
486 lprcat("by a platinum dragon who possesses psionic abilities. ");
487 cl_line(16, 14);
488 break;
489 }
490 time_used += coursetime[i - 'a'] * 100;
491 if (time_used > 0) {
492 gltime += time_used;
493 course[i - 'a']++; /* remember that he has
494 * taken that course */
495 c[HP] = c[HPMAX];
496 c[SPELLS] = c[SPELLMAX]; /* he regenerated */
497
498 if (c[BLINDCOUNT])
499 c[BLINDCOUNT] = 1; /* cure blindness too! */
500 if (c[CONFUSE])
501 c[CONFUSE] = 1; /* end confusion */
502 adjusttime((long) time_used); /* adjust parameters for
503 * time change */
504 }
505 nap(1000);
506 }
507 }
508 }
509
510
511 /*
512 * for the first national bank of Larn
513 */
514 int lasttime = 0; /* last time he was in bank */
515
516 void
517 obank(void)
518 {
519 banktitle(" Welcome to the First National Bank of Larn.");
520 }
521 void
522 obank2(void)
523 {
524 banktitle("Welcome to the 5th level branch office of the First National Bank of Larn.");
525 }
526
527 static void
528 banktitle(const char *str)
529 {
530 nosignal = 1; /* disable signals */
531 clear();
532 lprcat(str);
533 if (outstanding_taxes > 0) {
534 int i;
535 lprcat("\n\nThe Larn Revenue Service has ordered that your account be frozen until all\n");
536 beep();
537 lprintf("levied taxes have been paid. They have also told us that you owe %ld gp in\n", (long) outstanding_taxes);
538 lprcat("taxes, and we must comply with them. We cannot serve you at this time. Sorry.\n");
539 lprcat("We suggest you go to the LRS office and pay your taxes.\n");
540 cursors();
541 lprcat("\nPress ");
542 standout("escape");
543 lprcat(" to leave: ");
544 lflush();
545 i = 0;
546 while (i != '\33')
547 i = ttgetch();
548 drawscreen();
549 nosignal = 0; /* enable signals */
550 return;
551 }
552 lprcat("\n\n\tGemstone\t Appraisal\t\tGemstone\t Appraisal");
553 obanksub();
554 nosignal = 0; /* enable signals */
555 drawscreen();
556 }
557
558 /*
559 * function to put interest on your bank account
560 */
561 void
562 ointerest(void)
563 {
564 int i;
565 if (c[BANKACCOUNT] < 0)
566 c[BANKACCOUNT] = 0;
567 else if ((c[BANKACCOUNT] > 0) && (c[BANKACCOUNT] < 500000)) {
568 i = (gltime - lasttime) / 100; /* # mobuls elapsed */
569 while ((i-- > 0) && (c[BANKACCOUNT] < 500000))
570 c[BANKACCOUNT] += c[BANKACCOUNT] / 250;
571 if (c[BANKACCOUNT] > 500000)
572 c[BANKACCOUNT] = 500000; /* interest limit */
573 }
574 lasttime = (gltime / 100) * 100;
575 }
576
577 static short gemorder[26] = {0}; /* the reference to screen location
578 * for each */
579 static long gemvalue[26] = {0}; /* the appraisal of the gems */
580 void
581 obanksub(void)
582 {
583 long amt;
584 int i, k;
585 ointerest(); /* credit any needed interest */
586
587 for (k = i = 0; i < 26; i++)
588 switch (iven[i]) {
589 case OLARNEYE:
590 case ODIAMOND:
591 case OEMERALD:
592 case ORUBY:
593 case OSAPPHIRE:
594
595 if (iven[i] == OLARNEYE) {
596 gemvalue[i] = 250000 - ((gltime * 7) / 100) * 100;
597 if (gemvalue[i] < 50000)
598 gemvalue[i] = 50000;
599 } else
600 gemvalue[i] = (255 & ivenarg[i]) * 100;
601 gemorder[i] = k;
602 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
603 lprintf("%c) %s", i + 'a', objectname[iven[i]]);
604 cursor((k % 2) * 40 + 33, (k >> 1) + 4);
605 lprintf("%5ld", (long) gemvalue[i]);
606 k++;
607 };
608 cursor(31, 17);
609 lprintf("You have %8ld gold pieces in the bank.", (long) c[BANKACCOUNT]);
610 cursor(40, 18);
611 lprintf("You have %8ld gold pieces", (long) c[GOLD]);
612 if (c[BANKACCOUNT] + c[GOLD] >= 500000)
613 lprcat("\nNote: Larndom law states that only deposits under 500,000gp can earn interest.");
614 while (1) {
615 cl_dn(1, 20);
616 lprcat("\nYour wish? [(");
617 standout("d");
618 lprcat(") deposit, (");
619 standout("w");
620 lprcat(") withdraw, (");
621 standout("s");
622 lprcat(") sell a stone, or ");
623 standout("escape");
624 lprcat("] ");
625 yrepcount = 0;
626 i = 0;
627 while (i != 'd' && i != 'w' && i != 's' && i != '\33')
628 i = ttgetch();
629 switch (i) {
630 case 'd':
631 lprcat("deposit\nHow much? ");
632 amt = readnum((long) c[GOLD]);
633 if (amt < 0) {
634 lprcat("\nSorry, but we can't take negative gold!");
635 nap(2000);
636 amt = 0;
637 } else if (amt > c[GOLD]) {
638 lprcat(" You don't have that much.");
639 nap(2000);
640 } else {
641 c[GOLD] -= amt;
642 c[BANKACCOUNT] += amt;
643 }
644 break;
645
646 case 'w':
647 lprcat("withdraw\nHow much? ");
648 amt = readnum((long) c[BANKACCOUNT]);
649 if (amt < 0) {
650 lprcat("\nSorry, but we don't have any negative gold!");
651 nap(2000);
652 amt = 0;
653 } else if (amt > c[BANKACCOUNT]) {
654 lprcat("\nYou don't have that much in the bank!");
655 nap(2000);
656 } else {
657 c[GOLD] += amt;
658 c[BANKACCOUNT] -= amt;
659 }
660 break;
661
662 case 's':
663 lprcat("\nWhich stone would you like to sell? ");
664 i = 0;
665 while ((i < 'a' || i > 'z') && i != '*')
666 i = ttgetch();
667 if (i == '*')
668 for (i = 0; i < 26; i++) {
669 if (gemvalue[i]) {
670 c[GOLD] += gemvalue[i];
671 iven[i] = 0;
672 gemvalue[i] = 0;
673 k = gemorder[i];
674 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
675 lprintf("%39s", "");
676 }
677 }
678 else {
679 if (gemvalue[i = i - 'a'] == 0) {
680 lprintf("\nItem %c is not a gemstone!", i + 'a');
681 nap(2000);
682 break;
683 }
684 c[GOLD] += gemvalue[i];
685 iven[i] = 0;
686 gemvalue[i] = 0;
687 k = gemorder[i];
688 cursor((k % 2) * 40 + 1, (k >> 1) + 4);
689 lprintf("%39s", "");
690 }
691 break;
692
693 case '\33':
694 return;
695 };
696 cursor(40, 17);
697 lprintf("%8ld", (long) c[BANKACCOUNT]);
698 cursor(49, 18);
699 lprintf("%8ld", (long) c[GOLD]);
700 }
701 }
702
703 #if 0 /* XXX: apparently unused */
704 /*
705 subroutine to appraise any stone for the bank
706 */
707 static void
708 appraise(int gemstone)
709 {
710 int j, amt;
711 for (j = 0; j < 26; j++)
712 if (iven[j] == gemstone) {
713 lprintf("\nI see you have %s", objectname[gemstone]);
714 if (gemstone == OLARNEYE)
715 lprcat(" I must commend you. I didn't think\nyou could get it.");
716 lprcat(" Shall I appraise it for you? ");
717 yrepcount = 0;
718 if (getyn() == 'y') {
719 lprcat("yes.\n Just one moment please \n");
720 nap(1000);
721 if (gemstone == OLARNEYE) {
722 amt = 250000 - ((gltime * 7) / 100) * 100;
723 if (amt < 50000)
724 amt = 50000;
725 } else
726 amt = (255 & ivenarg[j]) * 100;
727 lprintf("\nI can see this is an excellent stone, It is worth %ld", (long) amt);
728 lprcat("\nWould you like to sell it to us? ");
729 yrepcount = 0;
730 if (getyn() == 'y') {
731 lprcat("yes\n");
732 c[GOLD] += amt;
733 iven[j] = 0;
734 } else
735 lprcat("no thank you.\n");
736 if (gemstone == OLARNEYE)
737 lprcat("It is, of course, your privilege to keep the stone\n");
738 } else
739 lprcat("no\nO. K.\n");
740 }
741 }
742 #endif /* 0 - unused */
743
744 /*
745 function for the trading post
746 */
747 static void
748 otradhead(void)
749 {
750 clear();
751 lprcat("Welcome to the Larn Trading Post. We buy items that explorers no longer find\n");
752 lprcat("useful. Since the condition of the items you bring in is not certain,\n");
753 lprcat("and we incur great expense in reconditioning the items, we usually pay\n");
754 lprcat("only 20% of their value were they to be new. If the items are badly\n");
755 lprcat("damaged, we will pay only 10% of their new value.\n\n");
756 }
757
758 void
759 otradepost(void)
760 {
761 int i, j, value, isub, izarg;
762 dnditm = dndcount = 0;
763 nosignal = 1; /* disable signals */
764 resetscroll();
765 otradhead();
766 while (1) {
767 lprcat("\nWhat item do you want to sell to us [");
768 standout("*");
769 lprcat(" for list, or ");
770 standout("escape");
771 lprcat("] ? ");
772 i = 0;
773 while (i > 'z' || (i < 'a' && i != '*' && i != '\33' && i != '.'))
774 i = ttgetch();
775 if (i == '\33') {
776 setscroll();
777 recalc();
778 drawscreen();
779 nosignal = 0; /* enable signals */
780 return;
781 }
782 isub = i - 'a';
783 j = 0;
784 if (iven[isub] == OSCROLL)
785 if (scrollname[ivenarg[isub]][0] == 0) {
786 j = 1;
787 cnsitm();
788 } /* can't sell unidentified item */
789 if (iven[isub] == OPOTION)
790 if (potionname[ivenarg[isub]][0] == 0) {
791 j = 1;
792 cnsitm();
793 } /* can't sell unidentified item */
794 if (!j) {
795 if (i == '*') {
796 clear();
797 qshowstr();
798 otradhead();
799 } else if (iven[isub] == 0)
800 lprintf("\nYou don't have item %c!", isub + 'a');
801 else {
802 for (j = 0; j < MAXITM; j++)
803 if ((itm[j].obj == iven[isub]) || (iven[isub] == ODIAMOND) || (iven[isub] == ORUBY) || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE)) {
804 srcount = 0;
805 show3(isub); /* show what the item
806 * was */
807 if ((iven[isub] == ODIAMOND) || (iven[isub] == ORUBY)
808 || (iven[isub] == OEMERALD) || (iven[isub] == OSAPPHIRE))
809 value = 20 * ivenarg[isub];
810 else if ((itm[j].obj == OSCROLL) || (itm[j].obj == OPOTION))
811 value = 2 * itm[j + ivenarg[isub]].price;
812 else {
813 izarg = ivenarg[isub];
814 value = itm[j].price; /* appreciate if a +n
815 * object */
816 if (izarg >= 0)
817 value *= 2;
818 while ((izarg-- > 0) && ((value = 14 * (67 + value) / 10) < 500000));
819 }
820 lprintf("\nItem (%c) is worth %ld gold pieces to us. Do you want to sell it? ", i, (long) value);
821 yrepcount = 0;
822 if (getyn() == 'y') {
823 lprcat("yes\n");
824 c[GOLD] += value;
825 if (c[WEAR] == isub)
826 c[WEAR] = -1;
827 if (c[WIELD] == isub)
828 c[WIELD] = -1;
829 if (c[SHIELD] == isub)
830 c[SHIELD] = -1;
831 adjustcvalues(iven[isub], ivenarg[isub]);
832 iven[isub] = 0;
833 } else
834 lprcat("no thanks.\n");
835 j = MAXITM + 100; /* get out of the inner
836 * loop */
837 }
838 if (j <= MAXITM + 2)
839 lprcat("\nSo sorry, but we are not authorized to accept that item.");
840 }
841 }
842 }
843 }
844
845 static void
846 cnsitm(void)
847 {
848 lprcat("\nSorry, we can't accept unidentified objects.");
849 }
850
851 /*
852 * for the Larn Revenue Service
853 */
854 void
855 olrs(void)
856 {
857 int i, first;
858 long amt;
859 first = nosignal = 1; /* disable signals */
860 clear();
861 resetscroll();
862 cursor(1, 4);
863 lprcat("Welcome to the Larn Revenue Service district office. How can we help you?");
864 while (1) {
865 if (first) {
866 first = 0;
867 goto nxt;
868 }
869 cursors();
870 lprcat("\n\nYour wish? [(");
871 standout("p");
872 lprcat(") pay taxes, or ");
873 standout("escape");
874 lprcat("] ");
875 yrepcount = 0;
876 i = 0;
877 while (i != 'p' && i != '\33')
878 i = ttgetch();
879 switch (i) {
880 case 'p':
881 lprcat("pay taxes\nHow much? ");
882 amt = readnum((long) c[GOLD]);
883 if (amt < 0) {
884 lprcat("\nSorry, but we can't take negative gold\n");
885 amt = 0;
886 } else if (amt > c[GOLD])
887 lprcat(" You don't have that much.\n");
888 else
889 c[GOLD] -= paytaxes(amt);
890 break;
891
892 case '\33':
893 nosignal = 0; /* enable signals */
894 setscroll();
895 drawscreen();
896 return;
897 };
898
899 nxt: cursor(1, 6);
900 if (outstanding_taxes > 0)
901 lprintf("You presently owe %ld gp in taxes. ", (long) outstanding_taxes);
902 else
903 lprcat("You do not owe us any taxes. ");
904 cursor(1, 8);
905 if (c[GOLD] > 0)
906 lprintf("You have %6ld gp. ", (long) c[GOLD]);
907 else
908 lprcat("You have no gold pieces. ");
909 }
910 }