Source:SLASH'EM 0.0.7E7F2/gypsy.c
Jump to navigation
Jump to search
Below is the full text to gypsy.c from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[Source:SLASH'EM 0.0.7E7F2/gypsy.c#line123]], for example.
Source code for vanilla NetHack is at Source code.
The NetHack General Public License applies to screenshots, source code and other content from NetHack.
This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.
1. /*** gypsy.c ***/ 2. 3. #include "hack.h" 4. #include "egyp.h" 5. #include "qtext.h" 6. 7. 8. /* To do: 9. * fortune_lev() 10. * Fourtunes for suited cards 11. * On-line help 12. */ 13. 14. 15. /*** Money-related functions ***/ 16. 17. static void 18. gypsy_charge (mtmp, amount) 19. struct monst *mtmp; 20. long amount; 21. { 22. #ifdef GOLDOBJ 23. struct obj *gypgold; 24. #endif 25. 26. /* Take from credit first */ 27. if (amount > EGYP(mtmp)->credit) { 28. /* Do in several steps, for broken compilers */ 29. amount -= EGYP(mtmp)->credit; 30. EGYP(mtmp)->credit = 0; 31. #ifdef GOLDOBJ 32. money2mon(mtmp, amount); 33. #else 34. u.ugold -= amount; 35. #endif 36. flags.botl = 1; 37. } else 38. EGYP(mtmp)->credit -= amount; 39. 40. /* The gypsy never carries cash; it might get stolen! */ 41. #ifdef GOLDOBJ 42. gypgold = findgold(mtmp->minvent); 43. if (gypgold) 44. m_useup(mtmp, gypgold); 45. #endif 46. return; 47. } 48. 49. static boolean 50. gypsy_offer (mtmp, cost, txt) 51. struct monst *mtmp; 52. long cost; 53. char *txt; 54. { 55. #ifdef GOLDOBJ 56. long umoney; 57. umoney = money_cnt(invent); 58. #endif 59. verbalize("For %ld credit I will %s!", cost, txt); 60. if (EGYP(mtmp)->credit >= cost) { 61. if (yn("Accept this offer?") == 'y') { 62. EGYP(mtmp)->credit -= cost; 63. return (TRUE); 64. } 65. #ifndef GOLDOBJ 66. } else if (EGYP(mtmp)->credit + u.ugold >= cost) 67. verbalize("What a pity that I can't accept gold!"); 68. #else 69. } else if (EGYP(mtmp)->credit + umoney >= cost) 70. verbalize("What a pity that I can't accept money!"); 71. #endif 72. /* Maybe you could try gambling some of it for credit... */ 73. else 74. verbalize("What a pity that you don't have enough!"); 75. return (FALSE); 76. } 77. 78. static long 79. gypsy_bet (mtmp, minimum) 80. struct monst *mtmp; 81. long minimum; 82. { 83. char prompt[BUFSZ], buf[BUFSZ]; 84. long bet = 0L; 85. #ifdef GOLDOBJ 86. long umoney; 87. umoney = money_cnt(invent); 88. #endif 89. 90. if (minimum > EGYP(mtmp)->credit + 91. #ifndef GOLDOBJ 92. u.ugold) { 93. #else 94. umoney) { 95. #endif 96. You("don't have enough money for the minimum bet."); 97. return (0L); 98. } 99. 100. /* Prompt for an amount */ 101. Sprintf(prompt, "Bet how much (%ld to %ld)?", minimum, 102. EGYP(mtmp)->credit + 103. #ifndef GOLDOBJ 104. u.ugold); 105. #else 106. umoney); 107. #endif 108. getlin(prompt, buf); 109. (void) sscanf(buf, "%ld", &bet); 110. 111. /* Validate the amount */ 112. if (bet == 0L) { 113. pline("Never mind."); 114. return (0L); 115. } 116. if (bet < minimum) { 117. You("must bet at least %ld.", minimum); 118. return (0L); 119. } 120. if (bet > EGYP(mtmp)->credit + 121. #ifndef GOLDOBJ 122. u.ugold) { 123. #else 124. umoney) { 125. #endif 126. You("don't have that much money to bet!"); 127. return (0L); 128. } 129. return (bet); 130. } 131. 132. 133. /*** Card-related functions ***/ 134. 135. static const char *suits[CARD_SUITS] = 136. { "swords", "wands", "shields", "rings" }; /* Special */ 137. /* swords wands/rods roses/cups pentacles/disks/coins Tarot */ 138. /* spade bastoni coppe denari Italian */ 139. /* swords batons cups coins (translated) */ 140. /* spades clubs hearts diamonds French */ 141. 142. 143. static const char *ranks[CARD_RANKS] = 144. { "ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", 145. /*none*/ "jack", "queen", "king" }; /* French */ 146. /* page/princess knight/prince queen king Tarot */ 147. 148. 149. static const char *trumps[CARD_TRUMPS] = 150. { "the Fool", /* This is NOT a Joker */ 151. "the Magician", /* same as the Magus */ 152. "the High Priestess", /* sometimes placed after the Emperor */ 153. #if 0 154. "the Empress", /* not included here */ 155. "the Emperor", /* not included here */ 156. #endif 157. "the Oracle", /* same as the Hierophant */ 158. "the Lovers", 159. "the Chariot", 160. "Strength", /* sometimes Adjustment */ 161. "the Hermit", 162. "the Wheel of Fortune", /* sometimes Fortune */ 163. "Justice", /* sometimes Lust */ 164. "Punishment", /* replaces the Hanged Man */ 165. "the Devil", /* normally #15 */ 166. "Sorcery", /* replaces Art or Temperance */ 167. "Death", /* swapped with the Devil so it remains #13 */ 168. "the Tower", /* really! */ 169. "the Star", 170. "the Moon", 171. "the Sun", 172. "Judgement", /* sometimes Aeon */ 173. "Infinity" /* replaces the World or the Universe */ 174. }; 175. 176. 177. static void 178. card_shuffle (mtmp) 179. struct monst *mtmp; 180. { 181. xchar *cards = &EGYP(mtmp)->cards[0]; 182. int i, j, k; 183. 184. 185. pline("%s shuffles the cards.", Monnam(mtmp)); 186. for (i = 0; i < CARD_TOTAL; i++) 187. /* Initialize the value */ 188. cards[i] = i; 189. for (i = 0; i < CARD_TOTAL; i++) { 190. /* Swap this value with another randomly chosen one */ 191. j = rn2(CARD_TOTAL); 192. k = cards[j]; 193. cards[j] = cards[i]; 194. cards[i] = k; 195. } 196. EGYP(mtmp)->top = CARD_TOTAL; 197. } 198. 199. static xchar 200. card_draw (mtmp) 201. struct monst *mtmp; 202. { 203. if (EGYP(mtmp)->top <= 0) 204. /* The deck is empty */ 205. return (-1); 206. return (EGYP(mtmp)->cards[--EGYP(mtmp)->top]); 207. } 208. 209. static void 210. card_name (num, buf) 211. xchar num; 212. char *buf; 213. { 214. int r, s; 215. 216. 217. if (!buf) return; 218. if (Hallucination) num = rn2(CARD_TOTAL); 219. if (num < 0 || num >= CARD_TOTAL) { 220. /* Invalid card */ 221. impossible("no such card %d", num); 222. Strcpy(buf, "a card"); 223. } else if (card_istrump(num)) { 224. /* Handle trump cards */ 225. r = card_trump(num); 226. if (!r) 227. Sprintf(buf, "the zero of trumps (%s)", trumps[r]); 228. else 229. Sprintf(buf, "the %d of trumps (%s)", r, trumps[r]); 230. } else { 231. /* Handle suited cards */ 232. r = card_rank(num); 233. s = card_suit(num); 234. Sprintf(buf, "the %s of %s", ranks[r], suits[s]); 235. } 236. return; 237. } 238. 239. 240. /*** Fortunes ***/ 241. 242. #define FORTUNE_COST 50 /* Cost to play */ 243. 244. static short birthstones[12] = 245. { 246. /* Jan */ GARNET, /* Feb */ AMETHYST, 247. /* Mar */ AQUAMARINE, /* Apr */ DIAMOND, 248. /* May */ EMERALD, /* Jun */ OPAL, 249. /* Jul */ RUBY, /* Aug */ CHRYSOBERYL, 250. /* Sep */ SAPPHIRE, /* Oct */ BLACK_OPAL, 251. /* Nov */ TOPAZ, /* Dec */ TURQUOISE 252. }; 253. 254. 255. static void 256. fortune_lev (mtmp, name, txt) 257. struct monst *mtmp; 258. char *name, *txt; 259. { 260. /*** FIXME -- still very buggy ***/ 261. /* d_level *lev;*/ 262. schar dep; 263. 264. 265. dep = lev_by_name(name); 266. if (!dep) { 267. /* Perhaps the level doesn't exist? */ 268. verbalize("The vision is hazy."); 269. return; 270. } 271. 272. if (dep == depth(&u.uz)) 273. verbalize("I see %s here.", txt); 274. else { 275. verbalize("I see %s on level %d.", txt, (int)dep); 276. /* if (gypsy_offer(mtmp, 5000L, "teleport you there")) 277. ;*/ 278. } 279. return; 280. } 281. 282. static void 283. fortune (mtmp) 284. struct monst *mtmp; 285. { 286. xchar card; 287. char buf[BUFSZ]; 288. short otyp; 289. struct obj *otmp; 290. 291. 292. /* Shuffle the deck, if neccessary, and draw a card */ 293. gypsy_charge(mtmp, FORTUNE_COST); 294. if (EGYP(mtmp)->top <= 0) 295. card_shuffle(mtmp); 296. card = card_draw(mtmp); 297. #ifdef WIZARD 298. if (wizard) { 299. long t = -1; 300. 301. getlin("Which trump?", buf); 302. (void) sscanf(buf, "%ld", &t); 303. if (t >= 0) card = t + CARD_SUITED; 304. } 305. #endif 306. card_name(card, buf); 307. verbalize("You have drawn %s.", buf); 308. 309. if (card_istrump(card)) 310. switch (card_trump(card)) { 311. case 0: /* the Fool */ 312. adjattrib(A_WIS, -1, 0); 313. change_luck(-3); 314. break; 315. case 1: /* the Magician */ 316. if (u.uevent.udemigod) 317. resurrect(); 318. else 319. fortune_lev(mtmp, "fakewiz1", 320. "an entrance to the Wizard's tower"); 321. /*fortune_lev(mtmp, &portal_level);*/ 322. break; 323. case 2: /* the High Priestess */ 324. if (u.uhave.amulet) 325. verbalize("I see a high altar in the heavens."); 326. /* Can only get there by ascending... */ 327. else 328. verbalize("I see a high altar on level %d.", 329. depth(&sanctum_level)); 330. /* Can only get there by invocation... */ 331. break; 332. case 3: /* the Oracle */ 333. fortune_lev(mtmp, "oracle", "the Oracle"); 334. /*fortune_lev(mtmp, &oracle_level);*/ 335. break; 336. case 4: /* the Lovers */ 337. makemon(&mons[flags.female ? PM_INCUBUS : PM_SUCCUBUS], 338. u.ux, u.uy, 0); 339. break; 340. case 5: /* the Chariot */ 341. if (gypsy_offer(mtmp, 5000L, 342. "teleport you to a level of your choosing")) { 343. incr_itimeout(&HTeleport_control, 1); 344. level_tele(); 345. } 346. break; 347. case 6: /* Strength */ 348. adjattrib(A_STR, 1, 0); 349. incr_itimeout(&HHalf_physical_damage, rn1(500, 500)); 350. break; 351. case 7: /* the Hermit */ 352. You_feel("like hiding!"); 353. incr_itimeout(&HTeleportation, rn1(300, 300)); 354. incr_itimeout(&HInvis, rn1(500, 500)); 355. newsym(u.ux, u.uy); 356. break; 357. case 8: /* the Wheel of Fortune */ 358. if (Hallucination) 359. pline("Where is Vanna?"); 360. else 361. You_feel("lucky!"); 362. if (u.uluck < 0) 363. u.uluck = 0; 364. else 365. change_luck(3); 366. break; 367. case 9: /* Justice */ 368. makemon(&mons[PM_ERINYS], u.ux, u.uy, 0); 369. break; 370. case 10: /* Punishment */ 371. if (!Punished) 372. punish((struct obj *)0); 373. else 374. rndcurse(); 375. break; 376. case 11: /* the Devil */ 377. summon_minion(A_NONE, TRUE); 378. break; 379. case 12: /* Sorcery */ 380. adjattrib(urole.spelstat, 1, 0); 381. incr_itimeout(&HHalf_spell_damage, rn1(500, 500)); 382. break; 383. case 13: /* Death */ 384. if (nonliving(youmonst.data) || is_demon(youmonst.data) 385. || Antimagic) 386. shieldeff(u.ux, u.uy); 387. else if(Hallucination) 388. You("have an out of body experience."); 389. else { 390. killer_format = KILLED_BY; 391. killer = "the card of Death"; 392. done(DIED); 393. } 394. break; 395. case 14: /* the Tower */ 396. fortune_lev(mtmp, "vlad\'s tower", "Vlad the Impaler"); 397. /* fortune_lev(mtmp, &vlad_level); */ 398. break; 399. case 15: /* the Star */ 400. otyp = birthstones[getmonth()]; 401. makeknown(otyp); 402. if ((otmp = mksobj(otyp, TRUE, FALSE)) != (struct obj *)0) { 403. pline("%s reaches behind your %s and pulls out %s.", 404. Monnam(mtmp), body_part(HEAD), doname(otmp)); 405. if (pickup_object(otmp, otmp->quan, FALSE) <= 0) { 406. obj_extract_self(otmp); 407. place_object(otmp, u.ux, u.uy); 408. newsym(u.ux, u.uy); 409. } 410. } 411. break; 412. case 16: /* the Moon */ 413. /* Reset the old moonphase */ 414. if (flags.moonphase == FULL_MOON) 415. change_luck(-1); 416. 417. /* Set the new moonphase */ 418. flags.moonphase = phase_of_the_moon(); 419. switch (flags.moonphase) { 420. case NEW_MOON: 421. pline("Be careful! New moon tonight."); 422. break; 423. case 1: case 2: case 3: 424. pline_The("moon is waxing tonight."); 425. break; 426. case FULL_MOON: 427. You("are lucky! Full moon tonight."); 428. change_luck(1); 429. break; 430. case 5: case 6: case 7: 431. pline_The("moon is waning tonight."); 432. break; 433. default: 434. impossible("wierd moonphase %d", flags.moonphase); 435. break; 436. } 437. break; 438. case 17: /* the Sun */ 439. if (midnight()) 440. verbalize("It is the witching hour. Beware of the undead!"); 441. else if (night()) 442. verbalize("It is nighttime. Beware of creatures of the night!"); 443. else 444. verbalize("It is daytime. Shouldn't you be working?"); 445. break; 446. case 18: /* Judgement */ 447. fortune_lev(mtmp, "portal to quest", 448. "a portal to a quest"); 449. /* fortune_lev(mtmp, &quest_level); */ 450. break; 451. case 19: /* Infinity */ 452. if (mtmp->mcan) { 453. verbalize("I wish I wasn't here!"); 454. mongone(mtmp); 455. } else if (gypsy_offer(mtmp, 10000L, "grant you a wish")) { 456. mtmp->mcan = TRUE; 457. makewish(); 458. } 459. break; 460. default: 461. impossible("unknown trump %d", card_trump(card)); 462. break; 463. } /* End trumps */ 464. else 465. /* Suited card */ 466. com_pager(QT_GYPSY + card); 467. 468. return; 469. } 470. 471. 472. /*** Three-card monte ***/ 473. 474. #define MONTE_COST 1 /* Minimum bet */ 475. #define MONTE_MAX 10 /* Maximum value of monteluck */ 476. 477. 478. static void 479. monte (mtmp) 480. struct monst *mtmp; 481. { 482. long bet, n; 483. char buf[BUFSZ]; 484. winid win; 485. anything any; 486. menu_item *selected; 487. int delta; 488. 489. 490. /* Get the bet */ 491. bet = gypsy_bet(mtmp, MONTE_COST); 492. if (!bet) return; 493. 494. /* Shuffle and pick */ 495. if (flags.verbose) 496. pline("%s places three cards and rearranges them.", Monnam(mtmp)); 497. any.a_void = 0; /* zero out all bits */ 498. win = create_nhwindow(NHW_MENU); 499. start_menu(win); 500. any.a_char = 'l'; 501. add_menu(win, NO_GLYPH, &any , 'l', 0, ATR_NONE, 502. "Left card", MENU_UNSELECTED); 503. any.a_char = 'c'; 504. add_menu(win, NO_GLYPH, &any , 'c', 0, ATR_NONE, 505. "Center card", MENU_UNSELECTED); 506. any.a_char = 'r'; 507. add_menu(win, NO_GLYPH, &any , 'r', 0, ATR_NONE, 508. "Right card", MENU_UNSELECTED); 509. end_menu(win, "Pick a card:"); 510. while (select_menu(win, PICK_ONE, &selected) != 1) ; 511. destroy_nhwindow(win); 512. 513. /* Calculate the change in odds for next time */ 514. /* Start out easy, but get harder once the player is suckered */ 515. delta = rnl(4) - 3; /* Luck helps */ 516. if (u.umontelast == selected[0].item.a_char) 517. /* Only suckers keep picking the same card */ 518. delta++; 519. u.umontelast = selected[0].item.a_char; 520. for (n = bet; n > 0; n /= 10L) 521. /* Penalize big bets */ 522. delta++; 523. /* pline("luck = %d; delta = %d", u.umonteluck, delta);*/ 524. 525. /* Did we win? */ 526. if (u.umonteluck <= rn2(MONTE_MAX)) { 527. if (u.umonteluck == 0) 528. verbalize("You win! Wasn't that easy?"); 529. else 530. verbalize("You win!"); 531. EGYP(mtmp)->credit += bet; 532. 533. /* Make it harder for next time */ 534. if (delta > 0) u.umonteluck += delta; 535. if (u.umonteluck > MONTE_MAX) u.umonteluck = MONTE_MAX; 536. } else { 537. card_name(rn1(2, 1), buf); 538. verbalize("Sorry, you picked %s. Try again.", buf); 539. gypsy_charge(mtmp, bet); 540. 541. /* Make it a little easier for next time */ 542. if (delta < 0) u.umonteluck += delta; 543. if (u.umonteluck < 0) u.umonteluck = 0; 544. } 545. return; 546. } 547. 548. 549. /*** Ninety-nine ***/ 550. 551. #define NINETYNINE_COST 1 /* Minimum bet */ 552. #define NINETYNINE_HAND 3 /* Number of cards in hand */ 553. #define NINETYNINE_GOAL 99 /* Limit of the total */ 554. 555. static boolean 556. nn_playable (card, total) 557. xchar card; 558. int total; 559. { 560. if (card_istrump(card)) 561. /* The fool always loses; other trumps are always playable */ 562. return (card != CARD_SUITED); 563. switch (card_rank(card)+1) { 564. case 11: /* Jack */ 565. case 12: /* Queen */ 566. return (total >= 10); 567. case 13: /* King */ 568. return (TRUE); 569. default: /* Ace through 10 */ 570. return ((total + card_rank(card) + 1) <= NINETYNINE_GOAL); 571. } 572. } 573. 574. static int 575. nn_play (card, total) 576. xchar card; 577. int total; 578. { 579. if (card_istrump(card)) { 580. if (card == CARD_SUITED) 581. /* The Fool always loses */ 582. return (NINETYNINE_GOAL+1); 583. else 584. /* Other trumps leave the total unchanged */ 585. return (total); 586. } 587. switch (card_rank(card)+1) { 588. case 11: /* Jack */ 589. case 12: /* Queen */ 590. return (total - 10); 591. case 13: /* King */ 592. return (NINETYNINE_GOAL); 593. default: /* Ace through 10 */ 594. return (total + card_rank(card) + 1); 595. } 596. } 597. 598. static int 599. nn_pref (card) 600. xchar card; 601. { 602. /* Computer's preferences for playing cards: 603. * 3. Get rid of Ace through 10 whenever we can. Highest priority. 604. * 2. King will challenge the player. High priority. 605. * 1. Jack and queen may help us, or the hero. Low priority. 606. * 0. Trumps can always be played (except the fool). Lowest priority. 607. */ 608. if (card_istrump(card)) 609. /* The fool always loses; other trumps are always playable */ 610. return (0); 611. switch (card_rank(card)+1) { 612. case 11: /* Jack */ 613. case 12: /* Queen */ 614. return (1); 615. case 13: /* King */ 616. return (2); 617. default: /* Ace through 10 */ 618. return (3); 619. } 620. } 621. 622. 623. static void 624. ninetynine (mtmp) 625. struct monst *mtmp; 626. { 627. long bet; 628. int i, n, which, total = 0; 629. xchar uhand[NINETYNINE_HAND], ghand[NINETYNINE_HAND]; 630. char buf[BUFSZ]; 631. winid win; 632. anything any; 633. menu_item *selected; 634. 635. 636. /* Get the bet */ 637. bet = gypsy_bet(mtmp, NINETYNINE_COST); 638. if (!bet) return; 639. 640. /* Shuffle the deck and deal */ 641. card_shuffle(mtmp); 642. for (i = 0; i < NINETYNINE_HAND; i++) { 643. uhand[i] = card_draw(mtmp); 644. ghand[i] = card_draw(mtmp); 645. } 646. 647. while (1) { 648. /* Let the user pick a card */ 649. any.a_void = 0; /* zero out all bits */ 650. win = create_nhwindow(NHW_MENU); 651. start_menu(win); 652. for (i = 0; i < NINETYNINE_HAND; i++) { 653. any.a_int = (nn_playable(uhand[i], total) ? i+1 : 0); 654. card_name(uhand[i], buf); 655. add_menu(win, NO_GLYPH, &any , 0, 0, ATR_NONE, 656. buf, MENU_UNSELECTED); 657. } 658. any.a_int = NINETYNINE_HAND + 1; 659. add_menu(win, NO_GLYPH, &any , 'q', 0, ATR_NONE, 660. "Forfeit", MENU_UNSELECTED); 661. end_menu(win, "Play a card:"); 662. while (select_menu(win, PICK_ONE, &selected) != 1) ; 663. destroy_nhwindow(win); 664. 665. /* Play the card */ 666. which = selected[0].item.a_int-1; 667. if (which >= NINETYNINE_HAND) { 668. You("forfeit."); 669. gypsy_charge(mtmp, bet); 670. return; 671. } 672. card_name(uhand[which], buf); 673. total = nn_play(uhand[which], total); 674. You("play %s for a total of %d.", buf, total); 675. if (total < 0 || total > NINETYNINE_GOAL) { 676. You("lose!"); 677. gypsy_charge(mtmp, bet); 678. return; 679. } 680. 681. /* Draw a new card */ 682. uhand[which] = card_draw(mtmp); 683. if (uhand[which] < 0) { 684. pline_The("deck is empty. You win!"); 685. EGYP(mtmp)->credit += bet; 686. return; 687. } 688. 689. /* Let the gypsy pick a card */ 690. n = 0; 691. for (i = 0; i < NINETYNINE_HAND; i++) 692. if (nn_playable(ghand[i], total)) { 693. /* The card is playable, but is it the best? */ 694. if (!n++ || nn_pref(ghand[i]) > nn_pref(ghand[which])) 695. which = i; 696. } 697. if (!n) { 698. /* No playable cards */ 699. pline("%s forfeits. You win!", Monnam(mtmp)); 700. EGYP(mtmp)->credit += bet; 701. return; 702. } 703. 704. /* Play the card */ 705. card_name(ghand[which], buf); 706. total = nn_play(ghand[which], total); 707. pline("%s plays %s for a total of %d.", Monnam(mtmp), buf, total); 708. 709. /* Draw a new card */ 710. ghand[which] = card_draw(mtmp); 711. if (ghand[which] < 0) { 712. pline_The("deck is empty. You win!"); 713. EGYP(mtmp)->credit += bet; 714. return; 715. } 716. } 717. 718. return; 719. } 720. 721. 722. 723. /*** Pawn gems ***/ 724. 725. STATIC_OVL NEARDATA const char pawnables[] = { ALLOW_COUNT, GEM_CLASS, 0 }; 726. 727. static void 728. pawn (mtmp) 729. struct monst *mtmp; 730. { 731. struct obj *otmp; 732. long value; 733. 734. 735. /* Prompt for an item */ 736. otmp = getobj((const char *)pawnables, "pawn"); 737. 738. /* Is the item valid? */ 739. if (!otmp) return; 740. if (!objects[otmp->otyp].oc_name_known) { 741. /* Reject unknown objects */ 742. verbalize("Is this merchandise authentic?"); 743. return; 744. } 745. if (otmp->otyp < DILITHIUM_CRYSTAL || otmp->otyp > LAST_GEM) { 746. /* Reject glass */ 747. verbalize("Don\'t bother with that junk!"); 748. return; 749. } 750. 751. /* Give the credit */ 752. value = otmp->quan * objects[otmp->otyp].oc_cost; 753. pline("%s gives you %ld zorkmid%s credit.", Monnam(mtmp), 754. value, plur(value)); 755. EGYP(mtmp)->credit += value; 756. 757. /* Gypsies don't keep merchandise; it could get stolen! */ 758. otmp->quan = 1L; 759. useup(otmp); 760. return; 761. } 762. 763. 764. /*** Yendorian Tarocchi ***/ 765. 766. #define TAROCCHI_COST 500 /* Cost to play */ 767. #define TAROCCHI_HAND 10 /* Number of cards in hand */ 768. 769. static void 770. tarocchi (mtmp) 771. struct monst *mtmp; 772. { 773. int turn; 774. 775. /* Shuffle the deck and deal */ 776. gypsy_charge(mtmp, TAROCCHI_COST); 777. card_shuffle(mtmp); 778. 779. /* Play the given number of turns */ 780. for (turn = TAROCCHI_HAND; turn > 0; turn--) { 781. } 782. 783. return; 784. } 785. 786. 787. /*** Monster-related functions ***/ 788. 789. void 790. gypsy_init (mtmp) 791. struct monst *mtmp; 792. { 793. mtmp->isgyp = TRUE; 794. mtmp->mpeaceful = TRUE; 795. mtmp->msleeping = 0; 796. mtmp->mtrapseen = ~0; /* traps are known */ 797. EGYP(mtmp)->credit = 0L; 798. EGYP(mtmp)->top = 0; 799. return; 800. } 801. 802. 803. void 804. gypsy_chat (mtmp) 805. struct monst *mtmp; 806. { 807. long money; 808. winid win; 809. anything any; 810. menu_item *selected; 811. #ifdef GOLDOBJ 812. long umoney; 813. #endif 814. int n; 815. 816. #ifdef GOLDOBJ 817. umoney = money_cnt(invent); 818. #endif 819. 820. /* Sanity checks */ 821. if (!mtmp || !mtmp->mpeaceful || !mtmp->isgyp || 822. !humanoid(mtmp->data)) 823. return; 824. 825. /* Add up your available money */ 826. You("have %ld zorkmid%s credit and are carrying %ld zorkmid%s.", 827. EGYP(mtmp)->credit, plur(EGYP(mtmp)->credit), 828. #ifndef GOLDOBJ 829. u.ugold, plur(u.ugold)); 830. #else 831. umoney, plur(umoney)); 832. #endif 833. money = EGYP(mtmp)->credit + 834. #ifndef GOLDOBJ 835. u.ugold; 836. #else 837. umoney; 838. #endif 839. 840. /* Create the menu */ 841. any.a_void = 0; /* zero out all bits */ 842. win = create_nhwindow(NHW_MENU); 843. start_menu(win); 844. 845. /* Fortune */ 846. any.a_char = 'f'; 847. if (money >= FORTUNE_COST) 848. add_menu(win, NO_GLYPH, &any , 'f', 0, ATR_NONE, 849. "Read your fortune", MENU_UNSELECTED); 850. 851. /* Three-card monte */ 852. any.a_char = 'm'; 853. if (money >= MONTE_COST) 854. add_menu(win, NO_GLYPH, &any , 'm', 0, ATR_NONE, 855. "Three-card monte", MENU_UNSELECTED); 856. 857. /* Ninety-nine */ 858. any.a_char = 'n'; 859. if (money >= NINETYNINE_COST) 860. add_menu(win, NO_GLYPH, &any , 'n', 0, ATR_NONE, 861. "Ninety-nine", MENU_UNSELECTED); 862. 863. /* Pawn gems (always available) */ 864. any.a_char = 'p'; 865. add_menu(win, NO_GLYPH, &any , 'p', 0, ATR_NONE, 866. "Pawn gems", MENU_UNSELECTED); 867. 868. /* Yendorian Tarocchi */ 869. any.a_char = 't'; 870. /* if (money >= TAROCCHI_COST) 871. add_menu(win, NO_GLYPH, &any , 't', 0, ATR_NONE, 872. "Yendorian Tarocchi", MENU_UNSELECTED);*/ 873. 874. /* Help */ 875. any.a_char = '?'; 876. add_menu(win, NO_GLYPH, &any , '?', 0, ATR_NONE, 877. "Help", MENU_UNSELECTED); 878. 879. /* Display the menu */ 880. end_menu(win, "Play which game?"); 881. n = select_menu(win, PICK_ONE, &selected); 882. destroy_nhwindow(win); 883. if (n > 0) switch (selected[0].item.a_char) { 884. case 'f': 885. fortune(mtmp); 886. break; 887. case 'm': 888. monte(mtmp); 889. break; 890. case 'n': 891. ninetynine(mtmp); 892. break; 893. case 'p': 894. pawn(mtmp); 895. break; 896. case 't': 897. tarocchi(mtmp); 898. break; 899. case '?': 900. display_file_area(FILE_AREA_SHARE, "gypsy.txt", TRUE); 901. break; 902. } 903. 904. return; 905. } 906. 907.