diff --git a/client/windows/CHeroWindow.cpp b/client/windows/CHeroWindow.cpp index 234d07285..74def291b 100644 --- a/client/windows/CHeroWindow.cpp +++ b/client/windows/CHeroWindow.cpp @@ -63,7 +63,8 @@ int64_t CHeroWithMaybePickedArtifact::getTreeVersion() const si32 CHeroWithMaybePickedArtifact::manaLimit() const { - return hero->manaLimit(); + //TODO: reduplicate code with CGHeroInstance + return si32(getPrimSkillLevel(PrimarySkill::KNOWLEDGE) * (valOfBonuses(Bonus::MANA_PER_KNOWLEDGE))); } CHeroWithMaybePickedArtifact::CHeroWithMaybePickedArtifact(CWindowWithArtifacts * Cww, const CGHeroInstance * Hero) diff --git a/client/windows/CHeroWindow.h b/client/windows/CHeroWindow.h index 6a8bf2dbe..263b50009 100644 --- a/client/windows/CHeroWindow.h +++ b/client/windows/CHeroWindow.h @@ -56,7 +56,7 @@ public: int64_t getTreeVersion() const override; - si32 manaLimit() const override; + si32 manaLimit() const; }; class CHeroWindow : public CStatusbarWindow, public CGarrisonHolder, public CWindowWithArtifacts diff --git a/include/vcmi/spells/Caster.h b/include/vcmi/spells/Caster.h index 123865a97..acd48cc6e 100644 --- a/include/vcmi/spells/Caster.h +++ b/include/vcmi/spells/Caster.h @@ -65,6 +65,8 @@ public: virtual void getCastDescription(const Spell * spell, const std::vector & attacked, MetaString & text) const = 0; virtual void spendMana(ServerCallback * server, const int32_t spellCost) const = 0; + + virtual int32_t manaLimit() const = 0; }; } diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 109b74e50..41c4e14a3 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -789,11 +789,6 @@ int IBonusBearer::getMaxDamage(bool ranged) const return valOfBonuses(selector, cachingStr); } -si32 IBonusBearer::manaLimit() const -{ - return 0; -} - int IBonusBearer::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const { static const CSelector selectorAllSkills = Selector::type()(Bonus::PRIMARY_SKILL); diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 195d4bc93..690f26b2a 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -752,7 +752,6 @@ public: virtual si32 magicResistance() const; ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators - virtual si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge) int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const; virtual int64_t getTreeVersion() const = 0; diff --git a/lib/battle/CUnitState.cpp b/lib/battle/CUnitState.cpp index fdb17a179..90b748b25 100644 --- a/lib/battle/CUnitState.cpp +++ b/lib/battle/CUnitState.cpp @@ -478,6 +478,11 @@ void CUnitState::getCastDescription(const spells::Spell * spell, const std::vect text.addReplacement(MetaString::SPELL_NAME, spell->getIndex()); } +int32_t CUnitState::manaLimit() const +{ + return 0; //TODO: creature casting with mana mode (for mods) +} + bool CUnitState::ableToRetaliate() const { return alive() diff --git a/lib/battle/CUnitState.h b/lib/battle/CUnitState.h index ee130edb6..a31789fd8 100644 --- a/lib/battle/CUnitState.h +++ b/lib/battle/CUnitState.h @@ -194,6 +194,7 @@ public: PlayerColor getCasterOwner() const override; void getCasterName(MetaString & text) const override; void getCastDescription(const spells::Spell * spell, const std::vector & attacked, MetaString & text) const override; + int32_t manaLimit() const override; bool ableToRetaliate() const override; bool alive() const override; diff --git a/lib/spells/ProxyCaster.cpp b/lib/spells/ProxyCaster.cpp index e93afe58c..9243975b5 100644 --- a/lib/spells/ProxyCaster.cpp +++ b/lib/spells/ProxyCaster.cpp @@ -86,6 +86,14 @@ void ProxyCaster::spendMana(ServerCallback * server, const int32_t spellCost) co actualCaster->spendMana(server, spellCost); } +int32_t ProxyCaster::manaLimit() const +{ + if(actualCaster) + return actualCaster->manaLimit(); + + return 0; +} + } VCMI_LIB_NAMESPACE_END diff --git a/lib/spells/ProxyCaster.h b/lib/spells/ProxyCaster.h index b3829da7f..9a2455c75 100644 --- a/lib/spells/ProxyCaster.h +++ b/lib/spells/ProxyCaster.h @@ -35,6 +35,7 @@ public: void getCasterName(MetaString & text) const override; void getCastDescription(const Spell * spell, const std::vector & attacked, MetaString & text) const override; void spendMana(ServerCallback * server, const int32_t spellCost) const override; + int32_t manaLimit() const override; private: const Caster * actualCaster; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 4ed3dad0f..cf0ed56d5 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -168,6 +168,11 @@ public: return owner; } + int32_t manaLimit() const override + { + return 0; + } + void getCasterName(MetaString & text) const override { logGlobal->error("Unexpected call to ObstacleCasterProxy::getCasterName");