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

Get rid of Bonus::sourceSpell()

* now bonus API looks more or less clean
This commit is contained in:
AlexVinS
2016-10-01 14:47:21 +03:00
parent c2a6c268c0
commit f124db9f61
5 changed files with 21 additions and 17 deletions

View File

@@ -1617,10 +1617,12 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
//removing all spells effects
auto selector = [](const Bonus * b)
{
const CSpell *s = b->sourceSpell();
//Special case: DISRUPTING_RAY is "immune" to dispell
//Other even PERMANENT effects can be removed
return (s != nullptr) && (s->id != SpellID::DISRUPTING_RAY);
if(b->source == Bonus::SPELL_EFFECT)
return b->sid != SpellID::DISRUPTING_RAY;
else
return false;
};
changedStack->popBonuses(selector);
}
@@ -1629,10 +1631,17 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
//removing all effects from negative spells
auto selector = [](const Bonus* b)
{
const CSpell *s = b->sourceSpell();
//Special case: DISRUPTING_RAY is "immune" to dispell
//Other even PERMANENT effects can be removed
return (s != nullptr) && s->isNegative() && (s->id != SpellID::DISRUPTING_RAY);
if(b->source == Bonus::SPELL_EFFECT)
{
const CSpell * sourceSpell = SpellID(b->sid).toSpell();
if(!sourceSpell)
return false;
return sourceSpell->id != SpellID::DISRUPTING_RAY && sourceSpell->isNegative();
}
else
return false;
};
changedStack->popBonuses(selector);
}