mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Do not allow to cast Cure if there is nothing to cure.
This commit is contained in:
parent
5e0a9d7966
commit
3fa62beb6d
@ -172,15 +172,8 @@ ESpellCastProblem::ESpellCastProblem CloneMechanics::isImmuneByStack(const ISpel
|
|||||||
void CureMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
|
void CureMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
|
||||||
{
|
{
|
||||||
DefaultSpellMechanics::applyBattle(battle, packet);
|
DefaultSpellMechanics::applyBattle(battle, packet);
|
||||||
doDispell(battle, packet, [](const Bonus * b) -> bool
|
|
||||||
{
|
doDispell(battle, packet, dispellSelector);
|
||||||
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
|
HealingSpellMechanics::EHealLevel CureMechanics::getHealLevel(int effectLevel) const
|
||||||
@ -188,6 +181,25 @@ HealingSpellMechanics::EHealLevel CureMechanics::getHealLevel(int effectLevel) c
|
|||||||
return EHealLevel::HEAL;
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
ESpellCastProblem::ESpellCastProblem CureMechanics::isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const
|
||||||
|
{
|
||||||
|
//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
|
///DispellMechanics
|
||||||
void DispellMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
|
void DispellMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
|
||||||
{
|
{
|
||||||
|
@ -63,8 +63,11 @@ public:
|
|||||||
CureMechanics(CSpell * s): HealingSpellMechanics(s){};
|
CureMechanics(CSpell * s): HealingSpellMechanics(s){};
|
||||||
|
|
||||||
void applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const override final;
|
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;
|
EHealLevel getHealLevel(int effectLevel) const override final;
|
||||||
|
private:
|
||||||
|
static bool dispellSelector(const Bonus * b);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics
|
class DLL_LINKAGE DispellMechanics : public DefaultSpellMechanics
|
||||||
|
Loading…
Reference in New Issue
Block a user