1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Use general dispell algorithm for CURE

This commit is contained in:
AlexVinS 2015-09-13 01:02:49 +03:00
parent 32337102ac
commit 843a2a39bd
2 changed files with 10 additions and 18 deletions

View File

@ -127,26 +127,15 @@ ESpellCastProblem::ESpellCastProblem CloneMechanics::isImmuneByStack(const CGHer
void CureMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast * packet) const
{
DefaultSpellMechanics::applyBattle(battle, packet);
for(auto stackID : packet->affectedCres)
doDispell(battle, packet, [](const Bonus * b) -> bool
{
if(vstd::contains(packet->resisted, stackID))
if(b->source == Bonus::SPELL_EFFECT)
{
logGlobal->errorStream() << "Resistance to positive spell CURE";
continue;
CSpell * sp = SpellID(b->sid).toSpell();
return sp->isNegative();
}
CStack *s = battle->getStack(stackID);
s->popBonuses([&](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
});
}
return false; //not a spell effect
});
}
///DispellMechanics

View File

@ -834,8 +834,11 @@ void DefaultSpellMechanics::doDispell(BattleInfo * battle, const BattleSpellCast
for(auto stackID : packet->affectedCres)
{
if(vstd::contains(packet->resisted, stackID))
{
if(owner->isPositive())
logGlobal->errorStream() <<"Resistance to positive spell " << owner->name;
continue;
}
CStack *s = battle->getStack(stackID);
s->popBonuses(selector);
}