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