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