1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Centralize dispell mechanics

This commit is contained in:
AlexVinS
2014-11-25 23:59:21 +03:00
parent 756c19227b
commit fe1233310f
5 changed files with 143 additions and 45 deletions

View File

@@ -1343,29 +1343,9 @@ DLL_LINKAGE void BattleSpellCast::applyGs( CGameState *gs )
}
}
//Handle spells removing effects from stacks
const CSpell *spell = SpellID(id).toSpell();
const bool removeAllSpells = id == SpellID::DISPEL;
const bool removeHelpful = id == SpellID::DISPEL_HELPFUL_SPELLS;
for(auto stackID : affectedCres)
{
if(vstd::contains(resisted, stackID))
continue;
CStack *s = gs->curB->getStack(stackID);
s->popBonuses([&](const Bonus *b) -> bool
{
//check for each bonus if it should be removed
const bool isSpellEffect = Selector::sourceType(Bonus::SPELL_EFFECT)(b);
const bool isPositiveSpell = Selector::positiveSpellEffects(b);
const int spellID = isSpellEffect ? b->sid : -1;
return (removeHelpful && isPositiveSpell)
|| (removeAllSpells && isSpellEffect)
|| vstd::contains(spell->counteredSpells, spellID);
});
}
const CSpell * spell = SpellID(id).toSpell();
spell->afterCast(gs->curB, this);
}
void actualizeEffect(CStack * s, const std::vector<Bonus> & ef)