From 0015027ec7724745c3bd4e85722ad4aeb934ff1c Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Thu, 13 Nov 2014 05:40:52 +0300 Subject: [PATCH] Draft fo CHAIN_LIGHTNING * fix usage of RECEPTIVE bonus --- lib/CSpellHandler.cpp | 15 ++++++++------- lib/SpellMechanics.cpp | 27 ++++++++++----------------- lib/SpellMechanics.h | 8 +++++--- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/lib/CSpellHandler.cpp b/lib/CSpellHandler.cpp index 2f45f909d..74f9aaefd 100644 --- a/lib/CSpellHandler.cpp +++ b/lib/CSpellHandler.cpp @@ -659,11 +659,7 @@ void CSpell::getEffects(std::vector& 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; diff --git a/lib/SpellMechanics.cpp b/lib/SpellMechanics.cpp index 9191f9c44..24f0232a4 100644 --- a/lib/SpellMechanics.cpp +++ b/lib/SpellMechanics.cpp @@ -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 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 diff --git a/lib/SpellMechanics.h b/lib/SpellMechanics.h index 39344f12c..351434511 100644 --- a/lib/SpellMechanics.h +++ b/lib/SpellMechanics.h @@ -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