From 46f99db8d7b602e3a462a39d92342a99ef6cc0cc Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Wed, 16 Sep 2015 10:50:33 +0300 Subject: [PATCH] Hide some spell mechnaics details --- lib/spells/CSpellHandler.cpp | 7 ------ lib/spells/CSpellHandler.h | 42 +++------------------------------- lib/spells/ISpellMechanics.cpp | 8 +++++++ lib/spells/ISpellMechanics.h | 40 ++++++++++++++++++++++++++++++++ server/CGameHandler.cpp | 1 + 5 files changed, 52 insertions(+), 46 deletions(-) diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index f4d18ae27..d84b6f108 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -71,13 +71,6 @@ namespace SpellConfig }; } -BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb) - : spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(nullptr), secHero(nullptr), - usedSpellPower(0),mode(ECastingMode::HERO_CASTING), casterStack(nullptr), selectedStack(nullptr), cb(cb) -{ - -} - ///CSpell::LevelInfo CSpell::LevelInfo::LevelInfo() :description(""),cost(0),power(0),AIValue(0),smartTarget(true), clearTarget(false), clearAffected(false), range("0") diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index 02c6ce613..920dccb4d 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -30,6 +30,9 @@ struct BattleSpellCast; class CGameInfoCallback; class CRandomGenerator; class CMap; +struct AdventureSpellCastParameters; +struct BattleSpellCastParameters; +class SpellCastEnvironment; struct SpellSchoolInfo { @@ -41,45 +44,6 @@ struct SpellSchoolInfo Bonus::BonusType knoledgeBonus; }; -///callback to be provided by server -class DLL_LINKAGE SpellCastEnvironment -{ -public: - virtual ~SpellCastEnvironment(){}; - virtual void sendAndApply(CPackForClient * info) const = 0; - - virtual CRandomGenerator & getRandomGenerator() const = 0; - virtual void complain(const std::string & problem) const = 0; - - virtual const CMap * getMap() const = 0; - virtual const CGameInfoCallback * getCb() const = 0; - - virtual bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) const =0; //TODO: remove -}; - -///helper struct -struct DLL_LINKAGE BattleSpellCastParameters -{ -public: - BattleSpellCastParameters(const BattleInfo * cb); - int spellLvl; - BattleHex destination; - ui8 casterSide; - PlayerColor casterColor; - const CGHeroInstance * casterHero; //deprecated - const CGHeroInstance * secHero; - int usedSpellPower; - ECastingMode::ECastingMode mode; - const CStack * casterStack; - const CStack * selectedStack; - const BattleInfo * cb; -}; - -struct DLL_LINKAGE AdventureSpellCastParameters -{ - const CGHeroInstance * caster; - int3 pos; -}; enum class VerticalPosition : ui8{TOP, CENTER, BOTTOM}; diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index d25a04090..8477d5444 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -17,6 +17,14 @@ #include "BattleSpellMechanics.h" #include "CreatureSpellMechanics.h" +BattleSpellCastParameters::BattleSpellCastParameters(const BattleInfo* cb) + : spellLvl(0), destination(BattleHex::INVALID), casterSide(0),casterColor(PlayerColor::CANNOT_DETERMINE),casterHero(nullptr), secHero(nullptr), + usedSpellPower(0),mode(ECastingMode::HERO_CASTING), casterStack(nullptr), selectedStack(nullptr), cb(cb) +{ + +} + + ///ISpellMechanics ISpellMechanics::ISpellMechanics(CSpell * s): owner(s) diff --git a/lib/spells/ISpellMechanics.h b/lib/spells/ISpellMechanics.h index 44986a5fc..1ccc1407b 100644 --- a/lib/spells/ISpellMechanics.h +++ b/lib/spells/ISpellMechanics.h @@ -15,6 +15,46 @@ #include "../BattleState.h" #include "../NetPacks.h" +///callback to be provided by server +class DLL_LINKAGE SpellCastEnvironment +{ +public: + virtual ~SpellCastEnvironment(){}; + virtual void sendAndApply(CPackForClient * info) const = 0; + + virtual CRandomGenerator & getRandomGenerator() const = 0; + virtual void complain(const std::string & problem) const = 0; + + virtual const CMap * getMap() const = 0; + virtual const CGameInfoCallback * getCb() const = 0; + + virtual bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) const =0; //TODO: remove +}; + +///helper struct +struct DLL_LINKAGE BattleSpellCastParameters +{ +public: + BattleSpellCastParameters(const BattleInfo * cb); + int spellLvl; + BattleHex destination; + ui8 casterSide; + PlayerColor casterColor; + const CGHeroInstance * casterHero; //deprecated + const CGHeroInstance * secHero; + int usedSpellPower; + ECastingMode::ECastingMode mode; + const CStack * casterStack; + const CStack * selectedStack; + const BattleInfo * cb; +}; + +struct DLL_LINKAGE AdventureSpellCastParameters +{ + const CGHeroInstance * caster; + int3 pos; +}; + class DLL_LINKAGE ISpellMechanics { public: diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 63fc7df81..cf6771201 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -10,6 +10,7 @@ #include "../lib/CBuildingHandler.h" #include "../lib/CHeroHandler.h" #include "../lib/spells/CSpellHandler.h" +#include "../lib/spells/ISpellMechanics.h" #include "../lib/CGeneralTextHandler.h" #include "../lib/CTownHandler.h" #include "../lib/CCreatureHandler.h"