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
|
int HealingSpellMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
||||||
{
|
{
|
||||||
if(parameters.effectValue != 0)
|
return parameters.getEffectValue();
|
||||||
return parameters.effectValue; //Archangel
|
|
||||||
return owner->calculateRawEffectValue(parameters.effectLevel, parameters.effectPower); //???
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///AntimagicMechanics
|
///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 SacrificeMechanics::calculateHealedHP(const SpellCastEnvironment* env, const BattleSpellCastParameters& parameters, SpellCastContext& ctx) const
|
||||||
{
|
{
|
||||||
int res = 0;
|
|
||||||
const CStack * victim = nullptr;
|
const CStack * victim = nullptr;
|
||||||
|
|
||||||
if(parameters.destinations.size() == 2)
|
if(parameters.destinations.size() == 2)
|
||||||
@ -726,8 +723,7 @@ int SacrificeMechanics::calculateHealedHP(const SpellCastEnvironment* env, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = (parameters.effectPower + victim->MaxHealth() + owner->getPower(parameters.effectLevel)) * victim->count;
|
return (parameters.effectPower + victim->MaxHealth() + owner->getPower(parameters.effectLevel)) * victim->count;
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SacrificeMechanics::requiresCreatureTarget() const
|
bool SacrificeMechanics::requiresCreatureTarget() const
|
||||||
|
@ -447,7 +447,7 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
//applying effects
|
//applying effects
|
||||||
if(owner->isOffensiveSpell())
|
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;
|
int chainLightningModifier = 0;
|
||||||
for(auto & attackedCre : ctx.attackedCres)
|
for(auto & attackedCre : ctx.attackedCres)
|
||||||
{
|
{
|
||||||
|
@ -88,6 +88,11 @@ BattleHex BattleSpellCastParameters::getFirstDestinationHex() const
|
|||||||
return destinations.at(0).hexValue;
|
return destinations.at(0).hexValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int BattleSpellCastParameters::getEffectValue() const
|
||||||
|
{
|
||||||
|
return (effectValue == 0) ? spell->calculateRawEffectValue(effectLevel, effectPower) : effectValue;
|
||||||
|
}
|
||||||
|
|
||||||
///ISpellMechanics
|
///ISpellMechanics
|
||||||
ISpellMechanics::ISpellMechanics(CSpell * s):
|
ISpellMechanics::ISpellMechanics(CSpell * s):
|
||||||
owner(s)
|
owner(s)
|
||||||
|
@ -58,6 +58,8 @@ public:
|
|||||||
|
|
||||||
BattleHex getFirstDestinationHex() const;
|
BattleHex getFirstDestinationHex() const;
|
||||||
|
|
||||||
|
int getEffectValue() const;
|
||||||
|
|
||||||
const CSpell * spell;
|
const CSpell * spell;
|
||||||
const BattleInfo * cb;
|
const BattleInfo * cb;
|
||||||
const ISpellCaster * caster;
|
const ISpellCaster * caster;
|
||||||
@ -78,6 +80,8 @@ public:
|
|||||||
int effectPower;
|
int effectPower;
|
||||||
///actual spell-power affecting effect duration
|
///actual spell-power affecting effect duration
|
||||||
int enchantPower;
|
int enchantPower;
|
||||||
|
|
||||||
|
private:
|
||||||
///for Archangel-like casting
|
///for Archangel-like casting
|
||||||
int effectValue;
|
int effectValue;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user