mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Get rid of Bonus::sourceSpell()
* now bonus API looks more or less clean
This commit is contained in:
parent
c2a6c268c0
commit
f124db9f61
@ -1044,13 +1044,6 @@ bool NBonus::hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int s
|
||||
return false;
|
||||
}
|
||||
|
||||
const CSpell * Bonus::sourceSpell() const
|
||||
{
|
||||
if(source == SPELL_EFFECT)
|
||||
return SpellID(sid).toSpell();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::string Bonus::Description() const
|
||||
{
|
||||
std::ostringstream str;
|
||||
|
@ -13,7 +13,6 @@
|
||||
*/
|
||||
|
||||
class CCreature;
|
||||
class CSpell;
|
||||
struct Bonus;
|
||||
class CBonusSystemNode;
|
||||
class ILimiter;
|
||||
@ -374,7 +373,6 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus>
|
||||
{
|
||||
val += Val;
|
||||
}
|
||||
const CSpell * sourceSpell() const;
|
||||
|
||||
std::string Description() const;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -53,9 +53,11 @@ void AntimagicMechanics::applyBattle(BattleInfo * battle, const BattleSpellCast
|
||||
|
||||
doDispell(battle, packet, [this](const Bonus *b) -> bool
|
||||
{
|
||||
const CSpell * sourceSpell = b->sourceSpell();
|
||||
if(sourceSpell != nullptr)
|
||||
if(b->source == Bonus::SPELL_EFFECT)
|
||||
{
|
||||
const CSpell * sourceSpell = SpellID(b->sid).toSpell();
|
||||
if(!sourceSpell)
|
||||
return false;//error
|
||||
//keep positive effects
|
||||
if(sourceSpell->isPositive())
|
||||
return false;
|
||||
|
@ -720,9 +720,11 @@ ESpellCastProblem::ESpellCastProblem DefaultSpellMechanics::isImmuneByStack(cons
|
||||
|
||||
bool DefaultSpellMechanics::dispellSelector(const Bonus * bonus)
|
||||
{
|
||||
const CSpell * sourceSpell = bonus->sourceSpell();
|
||||
if(sourceSpell != nullptr)
|
||||
if(bonus->source == Bonus::SPELL_EFFECT)
|
||||
{
|
||||
const CSpell * sourceSpell = SpellID(bonus->sid).toSpell();
|
||||
if(!sourceSpell)
|
||||
return false;//error
|
||||
//Special case: DISRUPTING_RAY is "immune" to dispell
|
||||
//Other even PERMANENT effects can be removed (f.e. BIND)
|
||||
if(sourceSpell->id == SpellID::DISRUPTING_RAY)
|
||||
|
Loading…
x
Reference in New Issue
Block a user