From 7bf8c9bd6952ac22c7952586cff1c33cb893d40b Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sat, 8 Jul 2017 21:20:38 +0300 Subject: [PATCH] fixed and cleanup --- client/CPlayerInterface.cpp | 3 +-- client/battle/CBattleInterface.cpp | 24 ++++++++++++------------ lib/CGeneralTextHandler.cpp | 2 +- lib/HeroBonus.cpp | 8 ++++---- lib/battle/BattleAttackInfo.cpp | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 3da51e2f6..07d434cab 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -710,9 +710,8 @@ void CPlayerInterface::battleStacksHealedRes(const std::vectordisplayEffect(52, attacker->position); //TODO: transparency CCS->soundh->playSound(soundBase::DRAINLIF); - int textID = CGI->generaltexth->pluralText(361, attacker->getCount()); MetaString text; - text.addTxt(MetaString::GENERAL_TXT, textID); + attacker->addText(text, MetaString::GENERAL_TXT, 361); attacker->addNameReplacement(text, false); text.addReplacement(healedStacks[0].second); defender->addNameReplacement(text, true); diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index ece8c1669..6f23bca1a 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -1365,18 +1365,18 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse) { //defensive stance const CStack * stack = LOCPLINT->cb->battleGetStackByID(*sse.stacks.begin()); + if(stack) + { + BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE))); + defenseBonuses.remove_if(Bonus::UntilGetsTurn); //remove bonuses gained from defensive stance + int val = stack->Defense() - defenseBonuses.totalValue(); - int textId = CGI->generaltexth->pluralText(120, stack->getCount()); - - BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE))); - defenseBonuses.remove_if(Bonus::UntilGetsTurn); //remove bonuses gained from defensive stance - int val = stack->Defense() - defenseBonuses.totalValue(); - - MetaString text; - text.addTxt(MetaString::GENERAL_TXT, textId); - stack->addNameReplacement(text); - text.addReplacement(val); - console->addText(text.toString()); + MetaString text; + stack->addText(text, MetaString::GENERAL_TXT, 120); + stack->addNameReplacement(text); + text.addReplacement(val); + console->addText(text.toString()); + } } } @@ -1752,7 +1752,7 @@ void CBattleInterface::printConsoleAttacked(const CStack * defender, int dmg, in if(attacker) //ignore if stacks were killed by spell { MetaString text; - text.addTxt(MetaString::GENERAL_TXT, CGI->generaltexth->pluralText(376, attacker->getCount())); + attacker->addText(text, MetaString::GENERAL_TXT, 376); attacker->addNameReplacement(text); text.addReplacement(dmg); formattedText = text.toString(); diff --git a/lib/CGeneralTextHandler.cpp b/lib/CGeneralTextHandler.cpp index 5a843a6ac..3fedd3b69 100644 --- a/lib/CGeneralTextHandler.cpp +++ b/lib/CGeneralTextHandler.cpp @@ -515,7 +515,7 @@ int32_t CGeneralTextHandler::pluralText(const int32_t textIndex, const int32_t c return 0; else if(textIndex < 0) return -textIndex; - else if(count == 1) + else if(count == 1) return textIndex; else return textIndex + 1; diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 949cdfa97..883aa81fc 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -90,11 +90,11 @@ TBonusListPtr CBonusProxy::get() const { if(CBonusSystemNode::treeChanged != cachedLast || !data) { - data = target->getAllBonuses(selector, nullptr); - data->eliminateDuplicates(); - cachedLast = CBonusSystemNode::treeChanged; + //TODO: support limiters + data = target->getAllBonuses(selector, nullptr); + data->eliminateDuplicates(); + cachedLast = CBonusSystemNode::treeChanged; } - return data; } diff --git a/lib/battle/BattleAttackInfo.cpp b/lib/battle/BattleAttackInfo.cpp index 5c5bb68a4..5066d302d 100644 --- a/lib/battle/BattleAttackInfo.cpp +++ b/lib/battle/BattleAttackInfo.cpp @@ -12,7 +12,7 @@ BattleAttackInfo::BattleAttackInfo(const CStack * Attacker, const CStack * Defender, bool Shooting): - attackerHealth(Attacker), defenderHealth(Defender) //todo: copy + attackerHealth(Attacker->health), defenderHealth(Defender->health) { attacker = Attacker; defender = Defender;