1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-04 00:15:53 +02:00

Draft fo CHAIN_LIGHTNING

* fix usage of RECEPTIVE bonus
This commit is contained in:
AlexVinS 2014-11-13 05:40:52 +03:00
parent a06dae1f96
commit 0015027ec7
3 changed files with 23 additions and 27 deletions

View File

@ -659,11 +659,7 @@ void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
} }
ESpellCastProblem::ESpellCastProblem CSpell::isImmuneBy(const IBonusBearer* obj) 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 //todo: use new bonus API
//1. Check absolute limiters //1. Check absolute limiters
for(auto b : absoluteLimiters) for(auto b : absoluteLimiters)
@ -678,6 +674,10 @@ ESpellCastProblem::ESpellCastProblem CSpell::isImmuneBy(const IBonusBearer* obj)
if (obj->hasBonusOfType(b)) if (obj->hasBonusOfType(b))
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
} }
//check receptivity
if (isPositive() && obj->hasBonusOfType(Bonus::RECEPTIVE)) //accept all positive spells
return ESpellCastProblem::OK;
//3. Check negation //3. Check negation
//FIXME: Orb of vulnerability mechanics is not such trivial //FIXME: Orb of vulnerability mechanics is not such trivial
@ -794,11 +794,12 @@ void CSpell::setupMechanics()
case SpellID::SACRIFICE: case SpellID::SACRIFICE:
mechanics = new SacrificeMechanics(this); mechanics = new SacrificeMechanics(this);
break; break;
case SpellID::CHAIN_LIGHTNING:
mechanics = new ChainLightningMechanics(this);
break;
default: default:
if(isRisingSpell()) if(isRisingSpell())
mechanics = new SpecialRisingSpellMechanics(this); mechanics = new SpecialRisingSpellMechanics(this);
else if(isOffensiveSpell())
mechanics = new OffenciveSpellMechnics(this);
else else
mechanics = new DefaultSpellMechanics(this); mechanics = new DefaultSpellMechanics(this);
break; break;

View File

@ -18,6 +18,16 @@
///DefaultSpellMechanics ///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 std::set<const CStack *> DefaultSpellMechanics::getAffectedStacks(SpellTargetingContext & ctx) const
{ {
@ -30,23 +40,6 @@ ESpellCastProblem::ESpellCastProblem DefaultSpellMechanics::isImmuneByStack(cons
return owner->isImmuneBy(obj); 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 ///CloneMechanics

View File

@ -25,11 +25,13 @@ public:
bool battleCast(SpellCastContext & context) const override; bool battleCast(SpellCastContext & context) const override;
}; };
class OffenciveSpellMechnics: public DefaultSpellMechanics
class ChainLightningMechanics: public DefaultSpellMechanics
{ {
public: public:
OffenciveSpellMechnics(CSpell * s): DefaultSpellMechanics(s){}; ChainLightningMechanics(CSpell * s): DefaultSpellMechanics(s){};
bool battleCast(SpellCastContext & context) const override;
}; };
class CloneMechanics: public DefaultSpellMechanics class CloneMechanics: public DefaultSpellMechanics