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