From 21c0c95049d048e1187eb2a4b790bcf308ab64b5 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 16 Jul 2017 01:53:13 +0300 Subject: [PATCH] tweak --- lib/spells/CDefaultSpellMechanics.cpp | 22 ++++++++++------------ lib/spells/CDefaultSpellMechanics.h | 4 +++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/spells/CDefaultSpellMechanics.cpp b/lib/spells/CDefaultSpellMechanics.cpp index f192a7017..daee01045 100644 --- a/lib/spells/CDefaultSpellMechanics.cpp +++ b/lib/spells/CDefaultSpellMechanics.cpp @@ -154,6 +154,14 @@ void SpellCastContext::setDamageToDisplay(const si32 value) damageToDisplay = value; } +void SpellCastContext::addCustomEffect(const CStack * target, ui32 effect) +{ + BattleSpellCast::CustomEffect customEffect; + customEffect.effect = effect; + customEffect.stack = target->ID; + sc.customEffects.push_back(customEffect); +} + void SpellCastContext::prepareBattleLog() { bool displayDamage = true; @@ -806,12 +814,7 @@ void DefaultSpellMechanics::handleMagicMirror(const SpellCastEnvironment * env, }); for(auto s : reflected) - { - BattleSpellCast::CustomEffect effect; - effect.effect = 3; - effect.stack = s->ID; - ctx.sc.customEffects.push_back(effect); - } + ctx.addCustomEffect(s, 3); } } @@ -839,12 +842,7 @@ void DefaultSpellMechanics::handleResistance(const SpellCastEnvironment * env, S }); for(auto s : resisted) - { - BattleSpellCast::CustomEffect effect; - effect.effect = 78; - effect.stack = s->ID; - ctx.sc.customEffects.push_back(effect); - } + ctx.addCustomEffect(s, 78); } } diff --git a/lib/spells/CDefaultSpellMechanics.h b/lib/spells/CDefaultSpellMechanics.h index 780f11801..4e89da0ef 100644 --- a/lib/spells/CDefaultSpellMechanics.h +++ b/lib/spells/CDefaultSpellMechanics.h @@ -21,7 +21,6 @@ public: const DefaultSpellMechanics * mechanics; const SpellCastEnvironment * env; std::vector attackedCres;//must be vector, as in Chain Lightning order matters - BattleSpellCast sc;//todo: make private StacksInjured si; const BattleSpellCastParameters & parameters; @@ -31,9 +30,12 @@ public: void addDamageToDisplay(const si32 value); void setDamageToDisplay(const si32 value); + void addCustomEffect(const CStack * target, ui32 effect); + void beforeCast(); void afterCast(); private: + BattleSpellCast sc; const CGHeroInstance * otherHero; int spellCost; si32 damageToDisplay;