mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-29 00:41:38 +02:00
Use CLONE and DISPEL_HELPFUL_SPELLS Mechanics classes in immunity caculation
This commit is contained in:
@ -146,8 +146,8 @@ CSpellMechanics::~CSpellMechanics()
|
||||
|
||||
ESpellCastProblem::ESpellCastProblem CSpellMechanics::isImmuneByStack(const CGHeroInstance * caster, ECastingMode::ECastingMode mode, const CStack * obj)
|
||||
{
|
||||
//by default no immunity
|
||||
return ESpellCastProblem::OK;
|
||||
//by default use general algorithm
|
||||
return owner->isImmuneBy(obj);
|
||||
}
|
||||
|
||||
namespace
|
||||
@ -166,6 +166,21 @@ namespace
|
||||
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, ECastingMode::ECastingMode mode, const CStack * obj) override;
|
||||
};
|
||||
|
||||
///all rising spells
|
||||
class RisingSpellMechanics: public CSpellMechanics
|
||||
{
|
||||
public:
|
||||
RisingSpellMechanics(CSpell * s): CSpellMechanics(s){};
|
||||
|
||||
};
|
||||
|
||||
///all rising spells but SACRIFICE
|
||||
class SpecialRisingSpellMechanics: public RisingSpellMechanics
|
||||
{
|
||||
public:
|
||||
SpecialRisingSpellMechanics(CSpell * s): RisingSpellMechanics(s){};
|
||||
ESpellCastProblem::ESpellCastProblem isImmuneByStack(const CGHeroInstance * caster, ECastingMode::ECastingMode mode, const CStack * obj) override;
|
||||
};
|
||||
|
||||
///CloneMechanics
|
||||
ESpellCastProblem::ESpellCastProblem CloneMechnics::isImmuneByStack(const CGHeroInstance* caster, ECastingMode::ECastingMode mode, const CStack * obj)
|
||||
@ -192,7 +207,7 @@ namespace
|
||||
if (maxLevel < creLevel) //tier 1-5 for basic, 1-6 for advanced, any level for expert
|
||||
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||
}
|
||||
|
||||
//use default algorithm only if there is no mechanics-related problem
|
||||
return CSpellMechanics::isImmuneByStack(caster,mode,obj);
|
||||
}
|
||||
|
||||
@ -212,10 +227,29 @@ namespace
|
||||
if(!hasPositiveSpell)
|
||||
{
|
||||
return ESpellCastProblem::NO_SPELLS_TO_DISPEL;
|
||||
}
|
||||
}
|
||||
|
||||
//use default algorithm only if there is no mechanics-related problem
|
||||
return CSpellMechanics::isImmuneByStack(caster,mode,obj);
|
||||
}
|
||||
|
||||
///SpecialRisingSpellMechanics
|
||||
ESpellCastProblem::ESpellCastProblem SpecialRisingSpellMechanics::isImmuneByStack(const CGHeroInstance* caster, ECastingMode::ECastingMode mode, const CStack* obj)
|
||||
{
|
||||
// // following does apply to resurrect and animate dead(?) only
|
||||
// // for sacrifice health calculation and health limit check don't matter
|
||||
//
|
||||
// if(obj->count >= obj->baseAmount)
|
||||
// return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||
//
|
||||
// if (caster) //FIXME: Archangels can cast immune stack
|
||||
// {
|
||||
// auto maxHealth = calculateHealedHP (caster, spell, obj);
|
||||
// if (maxHealth < obj->MaxHealth()) //must be able to rise at least one full creature
|
||||
// return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -592,13 +626,7 @@ ESpellCastProblem::ESpellCastProblem CSpell::isImmuneBy(const IBonusBearer* obj)
|
||||
|
||||
ESpellCastProblem::ESpellCastProblem CSpell::isImmuneByStack(const CGHeroInstance* caster, ECastingMode::ECastingMode mode, const CStack* obj) const
|
||||
{
|
||||
const auto immuneResult = isImmuneBy(obj);
|
||||
|
||||
if (ESpellCastProblem::NOT_DECIDED != immuneResult)
|
||||
return immuneResult;
|
||||
|
||||
return mechanics->isImmuneByStack(caster,mode,obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user