mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Hide effectValue calculation inside BattleSpellCastParameters
This commit is contained in:
parent
1fd87ecc4a
commit
73c7b49eb7
@ -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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user