From 29753a29a4b82d8cac78223232dc84c003d8f210 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 30 Jan 2015 19:18:43 -0500 Subject: XEEN: Implemented SpellsDialog and ConfirmDialog classes --- engines/xeen/town.cpp | 86 ++++++--------------------------------------------- 1 file changed, 10 insertions(+), 76 deletions(-) (limited to 'engines/xeen/town.cpp') diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index d773f6d4f2..2f31113146 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -606,7 +606,7 @@ Character *Town::doTavernOptions(Character *c) { case Common::KEYCODE_d: // Drink if (!c->noActions()) { - if (subtract(0, 1, 0, WT_2)) { + if (party.subtract(0, 1, 0, WT_2)) { sound.playSample(nullptr, 0); File f("gulp.voc"); sound.playSample(&f, 0); @@ -664,7 +664,7 @@ Character *Town::doTavernOptions(Character *c) { if (YesNo::show(_vm, false, true)) { if (party._food >= _v22) { ErrorScroll::show(_vm, FOOD_PACKS_FULL, WT_2); - } else if (subtract(0, _v23, 0, WT_2)) { + } else if (party.subtract(0, _v23, 0, WT_2)) { party._food = _v22; sound.playSample(nullptr, 0); File f(isDarkCc ? "thanks2.voc" : "thankyou.voc"); @@ -744,7 +744,7 @@ Character *Town::doTavernOptions(Character *c) { drawButtons(&screen); screen._windows[10].update(); townWait(); - } else if (subtract(0, 1, 0, WT_2)) { + } else if (party.subtract(0, 1, 0, WT_2)) { sound.playSample(nullptr, 0); File f(isDarkCc ? "thanks2.voc" : "thankyou.voc"); sound.playSample(&f, 1); @@ -805,7 +805,7 @@ Character *Town::doTempleOptions(Character *c) { break; case Common::KEYCODE_d: - if (_donation && subtract(0, _donation, 0, WT_2)) { + if (_donation && party.subtract(0, _donation, 0, WT_2)) { sound.playSample(nullptr, 0); File f("coina.voc"); sound.playSample(&f, 1); @@ -832,7 +832,7 @@ Character *Town::doTempleOptions(Character *c) { break; case Common::KEYCODE_h: - if (_healCost && subtract(0, _healCost, 0, WT_2)) { + if (_healCost && party.subtract(0, _healCost, 0, WT_2)) { c->_magicResistence._temporary = 0; c->_energyResistence._temporary = 0; c->_poisonResistence._temporary = 0; @@ -860,7 +860,7 @@ Character *Town::doTempleOptions(Character *c) { break; case Common::KEYCODE_u: - if (_uncurseCost && subtract(0, _uncurseCost, 0, WT_2)) { + if (_uncurseCost && party.subtract(0, _uncurseCost, 0, WT_2)) { for (int idx = 0; idx < 9; ++idx) { c->_weapons[idx]._bonusFlags &= ~FLAG_CURSED; c->_armor[idx]._bonusFlags &= ~FLAG_CURSED; @@ -921,7 +921,7 @@ Character *Town::doTrainingOptions(Character *c) { sound.playSample(&f); } else if (!c->noActions()) { - if (subtract(0, (c->_level._permanent * c->_level._permanent) * 10, 0, WT_2)) { + if (party.subtract(0, (c->_level._permanent * c->_level._permanent) * 10, 0, WT_2)) { _drawFrameIndex = 0; sound.playSample(nullptr, 0); File f(isDarkCc ? "prtygd.voc" : "trainin2.voc"); @@ -1003,14 +1003,14 @@ void Town::depositWithdrawl(int choice) { (choice && !party._bankGold && !flag) || (!choice && !party._gems && flag) || (!choice && !party._gold && !flag)) { - notEnough(flag, choice, 1, WT_2); + party.notEnough(flag, choice, 1, WT_2); } else { screen._windows[35].writeString(AMOUNT); int amount = NumericInput::show(_vm, 35, 10, 77); if (amount) { if (flag) { - if (subtract(true, amount, choice, WT_2)) { + if (party.subtract(true, amount, choice, WT_2)) { if (choice) { party._gems += amount; } else { @@ -1018,7 +1018,7 @@ void Town::depositWithdrawl(int choice) { } } } else { - if (subtract(false, amount, choice, WT_2)) { + if (party.subtract(false, amount, choice, WT_2)) { if (choice) { party._gold += amount; } else { @@ -1053,72 +1053,6 @@ void Town::depositWithdrawl(int choice) { _buttons[2]._value = Common::KEYCODE_ESCAPE; } -void Town::notEnough(int consumableId, int whereId, bool mode, ErrorWaitType wait) { - Common::String msg = Common::String::format( - mode ? NO_X_IN_THE_Y : NOT_ENOUGH_X_IN_THE_Y, - CONSUMABLE_NAMES[consumableId], WHERE_NAMES[whereId]); - ErrorScroll::show(_vm, msg, wait); -} - -int Town::subtract(int mode, uint amount, int whereId, ErrorWaitType wait) { - Party &party = *_vm->_party; - - switch (mode) { - case 0: - // Gold - if (whereId) { - if (amount <= party._bankGold) { - party._bankGold -= amount; - } else { - notEnough(0, whereId, false, wait); - return false; - } - } else { - if (amount <= party._gold) { - party._gold -= amount; - } else { - notEnough(0, whereId, false, wait); - return false; - } - } - break; - - case 1: - // Gems - if (whereId) { - if (amount <= party._bankGems) { - party._bankGems -= amount; - } else { - notEnough(0, whereId, false, wait); - return false; - } - } else { - if (amount <= party._gems) { - party._gems -= amount; - } else { - notEnough(0, whereId, false, wait); - return false; - } - } - break; - - case 2: - // Food - if (amount > party._food) { - party._food -= amount; - } else { - notEnough(5, 0, 0, wait); - return false; - } - break; - - default: - break; - } - - return true; -} - void Town::drawTownAnim(bool flag) { Interface &intf = *_vm->_interface; Screen &screen = *_vm->_screen; -- cgit v1.2.3