mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-30 23:18:08 +02:00
Draft fo CHAIN_LIGHTNING
* fix usage of RECEPTIVE bonus
This commit is contained in:
parent
a06dae1f96
commit
0015027ec7
@ -659,11 +659,7 @@ void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
|
||||
}
|
||||
|
||||
ESpellCastProblem::ESpellCastProblem CSpell::isImmuneBy(const IBonusBearer* obj) const
|
||||
{
|
||||
//0. check receptivity
|
||||
if (isPositive() && obj->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
|
||||
return ESpellCastProblem::OK;
|
||||
|
||||
{
|
||||
//todo: use new bonus API
|
||||
//1. Check absolute limiters
|
||||
for(auto b : absoluteLimiters)
|
||||
@ -678,6 +674,10 @@ ESpellCastProblem::ESpellCastProblem CSpell::isImmuneBy(const IBonusBearer* obj)
|
||||
if (obj->hasBonusOfType(b))
|
||||
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||
}
|
||||
|
||||
//check receptivity
|
||||
if (isPositive() && obj->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
|
||||
return ESpellCastProblem::OK;
|
||||
|
||||
//3. Check negation
|
||||
//FIXME: Orb of vulnerability mechanics is not such trivial
|
||||
@ -794,11 +794,12 @@ void CSpell::setupMechanics()
|
||||
case SpellID::SACRIFICE:
|
||||
mechanics = new SacrificeMechanics(this);
|
||||
break;
|
||||
case SpellID::CHAIN_LIGHTNING:
|
||||
mechanics = new ChainLightningMechanics(this);
|
||||
break;
|
||||
default:
|
||||
if(isRisingSpell())
|
||||
mechanics = new SpecialRisingSpellMechanics(this);
|
||||
else if(isOffensiveSpell())
|
||||
mechanics = new OffenciveSpellMechnics(this);
|
||||
else
|
||||
mechanics = new DefaultSpellMechanics(this);
|
||||
break;
|
||||
|
@ -18,6 +18,16 @@
|
||||
|
||||
///DefaultSpellMechanics
|
||||
|
||||
bool DefaultSpellMechanics::adventureCast(SpellCastContext& context) const
|
||||
{
|
||||
return false; //there is no general algorithm for castind adventure spells
|
||||
}
|
||||
|
||||
bool DefaultSpellMechanics::battleCast(SpellCastContext& context) const
|
||||
{
|
||||
return false; //todo; DefaultSpellMechanics::battleCast
|
||||
}
|
||||
|
||||
std::set<const CStack *> DefaultSpellMechanics::getAffectedStacks(SpellTargetingContext & ctx) const
|
||||
{
|
||||
|
||||
@ -30,23 +40,6 @@ ESpellCastProblem::ESpellCastProblem DefaultSpellMechanics::isImmuneByStack(cons
|
||||
return owner->isImmuneBy(obj);
|
||||
}
|
||||
|
||||
bool DefaultSpellMechanics::adventureCast(SpellCastContext& context) const
|
||||
{
|
||||
return false; //there is no general algorithm for castind adventure spells
|
||||
}
|
||||
|
||||
bool DefaultSpellMechanics::battleCast(SpellCastContext& context) const
|
||||
{
|
||||
return false; //todo; DefaultSpellMechanics::battleCast
|
||||
}
|
||||
|
||||
///OffenciveSpellMechnics
|
||||
bool OffenciveSpellMechnics::battleCast(SpellCastContext& context) const
|
||||
{
|
||||
assert(owner->isOffensiveSpell());
|
||||
|
||||
//todo:OffenciveSpellMechnics::battleCast
|
||||
}
|
||||
|
||||
|
||||
///CloneMechanics
|
||||
|
@ -25,11 +25,13 @@ public:
|
||||
bool battleCast(SpellCastContext & context) const override;
|
||||
};
|
||||
|
||||
class OffenciveSpellMechnics: public DefaultSpellMechanics
|
||||
|
||||
|
||||
class ChainLightningMechanics: public DefaultSpellMechanics
|
||||
{
|
||||
public:
|
||||
OffenciveSpellMechnics(CSpell * s): DefaultSpellMechanics(s){};
|
||||
bool battleCast(SpellCastContext & context) const override;
|
||||
ChainLightningMechanics(CSpell * s): DefaultSpellMechanics(s){};
|
||||
|
||||
};
|
||||
|
||||
class CloneMechanics: public DefaultSpellMechanics
|
||||
|
Loading…
Reference in New Issue
Block a user