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