1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Do not allow to cast Cure if there is nothing to cure.

This commit is contained in:
AlexVinS 2016-09-11 13:48:14 +03:00
parent 5e0a9d7966
commit 3fa62beb6d
2 changed files with 24 additions and 9 deletions

View File

@ -172,20 +172,32 @@ ESpellCastProblem::ESpellCastProblem CloneMechanics::isImmuneByStack(const ISpel
void CureMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
{
DefaultSpellMechanics::applyBattle(battle, packet);
doDispell(battle, packet, [](const Bonus * b) -> bool
{
doDispell(battle, packet, dispellSelector);
}
HealingSpellMechanics::EHealLevel CureMechanics::getHealLevel(int effectLevel) const
{
return EHealLevel::HEAL;
}
bool CureMechanics::dispellSelector(const Bonus * b)
{
if(b->source == Bonus::SPELL_EFFECT)
{
CSpell * sp = SpellID(b->sid).toSpell();
return sp->isNegative();
}
return false; //not a spell effect
});
}
HealingSpellMechanics::EHealLevel CureMechanics::getHealLevel(int effectLevel) const
ESpellCastProblem::ESpellCastProblem CureMechanics::isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const
{
return EHealLevel::HEAL;
//Selector method name is ok as cashing string. --AVS
if(!obj->canBeHealed() && !obj->hasBonus(dispellSelector, "CureMechanics::dispellSelector"))
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
return DefaultSpellMechanics::isImmuneByStack(caster, obj);
}
///DispellMechanics

View File

@ -63,8 +63,11 @@ public:
CureMechanics(CSpell * s): HealingSpellMechanics(s){};
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const override;
EHealLevel getHealLevel(int effectLevel) const override final;
private:
static bool dispellSelector(const Bonus * b);
};
class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics