mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
vcmi: magicResistance is IFactionMember property
It is no reason to keep it inside IBonusBearer
This commit is contained in:
@ -35,9 +35,13 @@ class DLL_LINKAGE IFactionMember: public IConstBonusProvider, public INativeTerr
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Returns native terrain considering some terrain bonuses.
|
Returns native terrain considering some terrain bonuses.
|
||||||
*/
|
*/
|
||||||
virtual Identifier<ETerrainId> getNativeTerrain() const;
|
virtual Identifier<ETerrainId> getNativeTerrain() const;
|
||||||
|
/**
|
||||||
|
Returns magic resistance considering some bonuses.
|
||||||
|
*/
|
||||||
|
virtual int32_t magicResistance() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DLL_LINKAGE Entity
|
class DLL_LINKAGE Entity
|
||||||
|
@ -38,4 +38,11 @@ TerrainId IFactionMember::getNativeTerrain() const
|
|||||||
? any : VLC->factions()->getById(getFaction())->getNativeTerrain();
|
? any : VLC->factions()->getById(getFaction())->getNativeTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t IFactionMember::magicResistance() const
|
||||||
|
{
|
||||||
|
si32 val = getBonusBearer()->valOfBonuses(Selector::type()(Bonus::MAGIC_RESISTANCE));
|
||||||
|
vstd::amin (val, 100);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
@ -736,13 +736,6 @@ int CStackInstance::getLevel() const
|
|||||||
return std::max(1, static_cast<int>(type->getLevel()));
|
return std::max(1, static_cast<int>(type->getLevel()));
|
||||||
}
|
}
|
||||||
|
|
||||||
si32 CStackInstance::magicResistance() const
|
|
||||||
{
|
|
||||||
si32 val = valOfBonuses(Selector::type()(Bonus::MAGIC_RESISTANCE));
|
|
||||||
vstd::amin (val, 100);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CStackInstance::giveStackExp(TExpType exp)
|
void CStackInstance::giveStackExp(TExpType exp)
|
||||||
{
|
{
|
||||||
int level = type->getLevel();
|
int level = type->getLevel();
|
||||||
|
@ -106,7 +106,6 @@ public:
|
|||||||
std::string getQuantityTXT(bool capitalized = true) const;
|
std::string getQuantityTXT(bool capitalized = true) const;
|
||||||
virtual int getExpRank() const;
|
virtual int getExpRank() const;
|
||||||
virtual int getLevel() const; //different for regular stack and commander
|
virtual int getLevel() const; //different for regular stack and commander
|
||||||
si32 magicResistance() const override;
|
|
||||||
CreatureID getCreatureID() const; //-1 if not available
|
CreatureID getCreatureID() const; //-1 if not available
|
||||||
std::string getName() const; //plural or singular
|
std::string getName() const; //plural or singular
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <vstd/RNG.h>
|
#include <vstd/RNG.h>
|
||||||
|
|
||||||
|
#include <vcmi/Entity.h>
|
||||||
#include <vcmi/ServerCallback.h>
|
#include <vcmi/ServerCallback.h>
|
||||||
|
|
||||||
#include "CGeneralTextHandler.h"
|
#include "CGeneralTextHandler.h"
|
||||||
@ -88,7 +89,7 @@ ui32 CStack::level() const
|
|||||||
|
|
||||||
si32 CStack::magicResistance() const
|
si32 CStack::magicResistance() const
|
||||||
{
|
{
|
||||||
auto magicResistance = IBonusBearer::magicResistance();
|
auto magicResistance = IFactionMember::magicResistance();
|
||||||
|
|
||||||
si32 auraBonus = 0;
|
si32 auraBonus = 0;
|
||||||
|
|
||||||
|
@ -795,11 +795,6 @@ int IBonusBearer::getPrimSkillLevel(PrimarySkill::PrimarySkill id) const
|
|||||||
return ret; //sp=0 works in old saves
|
return ret; //sp=0 works in old saves
|
||||||
}
|
}
|
||||||
|
|
||||||
si32 IBonusBearer::magicResistance() const
|
|
||||||
{
|
|
||||||
return valOfBonuses(Bonus::MAGIC_RESISTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui32 IBonusBearer::Speed(int turn, bool useBind) const
|
ui32 IBonusBearer::Speed(int turn, bool useBind) const
|
||||||
{
|
{
|
||||||
//war machines cannot move
|
//war machines cannot move
|
||||||
|
@ -760,7 +760,6 @@ public:
|
|||||||
|
|
||||||
ui32 MaxHealth() const; //get max HP of stack with all modifiers
|
ui32 MaxHealth() const; //get max HP of stack with all modifiers
|
||||||
bool isLiving() const; //non-undead, non-non living or alive
|
bool isLiving() const; //non-undead, non-non living or alive
|
||||||
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
|
||||||
|
|
||||||
int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;
|
int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;
|
||||||
|
Reference in New Issue
Block a user