+ move(5, 36);
+ ch = getanswer("LPS", FALSE);
+ move(15, 0);
+ clrtobot();
+ switch (ch) {
+ case 'L': /* leave */
+ case '\n':
+ altercoordinates(0.0, 0.0, A_NEAR);
+ return;
+
+ case 'P': /* make purchase */
+ mvaddstr(15, 0, "What what would you like to buy ? ");
+ ch = getanswer(" 1234567", FALSE);
+ move(15, 0);
+ clrtoeol();
+
+ if (ch - '0' > size)
+ addstr("Sorry, this merchant doesn't have that.");
+ else
+ switch (ch) {
+ case '1':
+ printw("Mana is one per %.0f gold piece. How many do you want (%.0f max) ? ",
+ Menu[0].cost, floor(Player.p_gold / Menu[0].cost));
+ cost = (numitems = floor(infloat())) * Menu[0].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_mana += numitems;
+ }
+ break;
+
+ case '2':
+ printw("Shields are %.0f per +1. How many do you want (%.0f max) ? ",
+ Menu[1].cost, floor(Player.p_gold / Menu[1].cost));
+ cost = (numitems = floor(infloat())) * Menu[1].cost;
+
+ if (numitems == 0.0)
+ break;
+ else
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ if (numitems < Player.p_shield)
+ NOBETTER();
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_shield = numitems;
+ }
+ break;
+
+ case '3':
+ printw("A book costs %.0f gp. How many do you want (%.0f max) ? ",
+ Menu[2].cost, floor(Player.p_gold / Menu[2].cost));
+ cost = (numitems = floor(infloat())) * Menu[2].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ if (drandom() * numitems > Player.p_level / 10.0
+ && numitems != 1) {
+ printw("\nYou blew your mind!\n");
+ Player.p_brains /= 5;
+ } else {
+ Player.p_brains += floor(numitems) * ROLL(20, 8);
+ }
+ }
+ break;
+
+ case '4':
+ printw("Swords are %.0f gp per +1. How many + do you want (%.0f max) ? ",
+ Menu[3].cost, floor(Player.p_gold / Menu[3].cost));
+ cost = (numitems = floor(infloat())) * Menu[3].cost;
+
+ if (numitems == 0.0)
+ break;
+ else
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ if (numitems < Player.p_sword)
+ NOBETTER();
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_sword = numitems;
+ }
+ break;
+
+ case '5':
+ printw("A charm costs %.0f gp. How many do you want (%.0f max) ? ",
+ Menu[4].cost, floor(Player.p_gold / Menu[4].cost));
+ cost = (numitems = floor(infloat())) * Menu[4].cost;
+
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_charms += numitems;
+ }
+ break;
+
+ case '6':
+ printw("Quicksilver is %.0f gp per +1. How many + do you want (%.0f max) ? ",
+ Menu[5].cost, floor(Player.p_gold / Menu[5].cost));
+ cost = (numitems = floor(infloat())) * Menu[5].cost;
+
+ if (numitems == 0.0)
+ break;
+ else
+ if (cost > Player.p_gold || numitems < 0)
+ ++cheat;
+ else
+ if (numitems < Player.p_quksilver)
+ NOBETTER();
+ else {
+ cheat = 0;
+ Player.p_gold -= cost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_quksilver = numitems;
+ }
+ break;
+
+ case '7':
+ if (Player.p_blessing) {
+ addstr("You already have a blessing.");
+ break;
+ }
+ printw("A blessing requires a %.0f gp donation. Still want one ? ", blessingcost);
+ ch = getanswer("NY", FALSE);
+
+ if (ch == 'Y') {
+ if (Player.p_gold < blessingcost)
+ ++cheat;
+ else {
+ cheat = 0;
+ Player.p_gold -= blessingcost;
+ if (drandom() < 0.02)
+ dishonest = TRUE;
+ else
+ Player.p_blessing = TRUE;
+ }
+ }
+ break;