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