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