浏览代码

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

AlexVinS 9 年之前
父节点
当前提交
3fa62beb6d
共有 2 个文件被更改,包括 24 次插入9 次删除
  1. 21 9
      lib/spells/BattleSpellMechanics.cpp
  2. 3 0
      lib/spells/BattleSpellMechanics.h

+ 21 - 9
lib/spells/BattleSpellMechanics.cpp

@@ -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
-	{
-		if(b->source == Bonus::SPELL_EFFECT)
-		{
-			CSpell * sp = SpellID(b->sid).toSpell();
-			return sp->isNegative();
-		}
-		return false; //not a spell effect
-	});
+
+	doDispell(battle, packet, dispellSelector);
 }
 }
 
 
 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
 {
 {

+ 3 - 0
lib/spells/BattleSpellMechanics.h

@@ -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