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