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