diff --git a/lib/spells/BattleSpellMechanics.cpp b/lib/spells/BattleSpellMechanics.cpp index 1a535e4de..6a6a62172 100644 --- a/lib/spells/BattleSpellMechanics.cpp +++ b/lib/spells/BattleSpellMechanics.cpp @@ -41,9 +41,7 @@ void HealingSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env, int HealingSpellMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const { - if(parameters.effectValue != 0) - return parameters.effectValue; //Archangel - return owner->calculateRawEffectValue(parameters.effectLevel, parameters.effectPower); //??? + return parameters.getEffectValue(); } ///AntimagicMechanics @@ -712,7 +710,6 @@ void SacrificeMechanics::applyBattleEffects(const SpellCastEnvironment * env, co int SacrificeMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const { - int res = 0; const CStack * victim = nullptr; if(parameters.destinations.size() == 2) @@ -726,8 +723,7 @@ int SacrificeMechanics::calculateHealedHP(const SpellCastEnvironment* env, const return 0; } - res = (parameters.effectPower + victim->MaxHealth() + owner->getPower(parameters.effectLevel)) * victim->count; - return res; + return (parameters.effectPower + victim->MaxHealth() + owner->getPower(parameters.effectLevel)) * victim->count; } bool SacrificeMechanics::requiresCreatureTarget() const diff --git a/lib/spells/CDefaultSpellMechanics.cpp b/lib/spells/CDefaultSpellMechanics.cpp index 6b95c5768..156fe55ef 100644 --- a/lib/spells/CDefaultSpellMechanics.cpp +++ b/lib/spells/CDefaultSpellMechanics.cpp @@ -447,7 +447,7 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env, //applying effects if(owner->isOffensiveSpell()) { - const int rawDamage = (parameters.effectValue == 0) ? owner->calculateRawEffectValue(parameters.effectLevel, parameters.effectPower) : parameters.effectValue; + const int rawDamage = parameters.getEffectValue(); int chainLightningModifier = 0; for(auto & attackedCre : ctx.attackedCres) { diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index fabe2ea4e..163cedf91 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -88,6 +88,11 @@ BattleHex BattleSpellCastParameters::getFirstDestinationHex() const return destinations.at(0).hexValue; } +int BattleSpellCastParameters::getEffectValue() const +{ + return (effectValue == 0) ? spell->calculateRawEffectValue(effectLevel, effectPower) : effectValue; +} + ///ISpellMechanics ISpellMechanics::ISpellMechanics(CSpell * s): owner(s) diff --git a/lib/spells/ISpellMechanics.h b/lib/spells/ISpellMechanics.h index 6636c836e..f7463344c 100644 --- a/lib/spells/ISpellMechanics.h +++ b/lib/spells/ISpellMechanics.h @@ -58,6 +58,8 @@ public: BattleHex getFirstDestinationHex() const; + int getEffectValue() const; + const CSpell * spell; const BattleInfo * cb; const ISpellCaster * caster; @@ -78,6 +80,8 @@ public: int effectPower; ///actual spell-power affecting effect duration int enchantPower; + +private: ///for Archangel-like casting int effectValue; };