Ver Fonte

vcmi: manaLimit should be spellcaster property

Konstantin há 2 anos atrás
pai
commit
4f3c826196

+ 2 - 0
include/vcmi/spells/Caster.h

@@ -65,6 +65,8 @@ public:
 	virtual void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const = 0;
 	virtual void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const = 0;
 
 
 	virtual void spendMana(ServerCallback * server, const int32_t spellCost) const = 0;
 	virtual void spendMana(ServerCallback * server, const int32_t spellCost) const = 0;
+
+	virtual int32_t manaLimit() const = 0;
 };
 };
 
 
 }
 }

+ 0 - 5
lib/HeroBonus.cpp

@@ -789,11 +789,6 @@ int IBonusBearer::getMaxDamage(bool ranged) const
 	return valOfBonuses(selector, cachingStr);
 	return valOfBonuses(selector, cachingStr);
 }
 }
 
 
-si32 IBonusBearer::manaLimit() const
-{
-	return 0;
-}
-
 int IBonusBearer::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const
 int IBonusBearer::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const
 {
 {
 	static const CSelector selectorAllSkills = Selector::type()(Bonus::PRIMARY_SKILL);
 	static const CSelector selectorAllSkills = Selector::type()(Bonus::PRIMARY_SKILL);

+ 0 - 1
lib/HeroBonus.h

@@ -752,7 +752,6 @@ public:
 	virtual si32 magicResistance() const;
 	virtual si32 magicResistance() const;
 	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
 	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;
 	int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;
 
 
 	virtual int64_t getTreeVersion() const = 0;
 	virtual int64_t getTreeVersion() const = 0;

+ 5 - 0
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());
 	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
 bool CUnitState::ableToRetaliate() const
 {
 {
 	return alive()
 	return alive()

+ 1 - 0
lib/battle/CUnitState.h

@@ -194,6 +194,7 @@ public:
 	PlayerColor getCasterOwner() const override;
 	PlayerColor getCasterOwner() const override;
 	void getCasterName(MetaString & text) const override;
 	void getCasterName(MetaString & text) const override;
 	void getCastDescription(const spells::Spell * spell, const std::vector<const Unit *> & attacked, MetaString & text) const override;
 	void getCastDescription(const spells::Spell * spell, const std::vector<const Unit *> & attacked, MetaString & text) const override;
+	int32_t manaLimit() const override;
 
 
 	bool ableToRetaliate() const override;
 	bool ableToRetaliate() const override;
 	bool alive() const override;
 	bool alive() const override;

+ 8 - 0
lib/spells/ProxyCaster.cpp

@@ -86,6 +86,14 @@ void ProxyCaster::spendMana(ServerCallback * server, const int32_t spellCost) co
 	actualCaster->spendMana(server, spellCost);
 	actualCaster->spendMana(server, spellCost);
 }
 }
 
 
+int32_t ProxyCaster::manaLimit() const
+{
+	if(actualCaster)
+		return actualCaster->manaLimit();
+
+	return 0;
+}
+
 }
 }
 
 
 VCMI_LIB_NAMESPACE_END
 VCMI_LIB_NAMESPACE_END

+ 1 - 0
lib/spells/ProxyCaster.h

@@ -35,6 +35,7 @@ public:
 	void getCasterName(MetaString & text) const override;
 	void getCasterName(MetaString & text) const override;
 	void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const override;
 	void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const override;
 	void spendMana(ServerCallback * server, const int32_t spellCost) const override;
 	void spendMana(ServerCallback * server, const int32_t spellCost) const override;
+	int32_t manaLimit() const override;
 
 
 private:
 private:
 	const Caster * actualCaster;
 	const Caster * actualCaster;