mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
code review
This commit is contained in:
@@ -38,7 +38,6 @@ public:
|
|||||||
virtual ~Caster() = default;
|
virtual ~Caster() = default;
|
||||||
|
|
||||||
virtual int32_t getCasterUnitId() const = 0;
|
virtual int32_t getCasterUnitId() const = 0;
|
||||||
virtual BattleHex getCasterPosition() const = 0;
|
|
||||||
|
|
||||||
/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
|
/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
|
||||||
/// caster may not know this spell at all
|
/// caster may not know this spell at all
|
||||||
|
|||||||
@@ -407,11 +407,6 @@ int32_t CUnitState::getCasterUnitId() const
|
|||||||
return static_cast<int32_t>(unitId());
|
return static_cast<int32_t>(unitId());
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleHex CUnitState::getCasterPosition() const
|
|
||||||
{
|
|
||||||
return getPosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
const CGHeroInstance * CUnitState::getHeroCaster() const
|
const CGHeroInstance * CUnitState::getHeroCaster() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -170,7 +170,6 @@ public:
|
|||||||
int32_t creatureIconIndex() const override;
|
int32_t creatureIconIndex() const override;
|
||||||
|
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
BattleHex getCasterPosition() const override;
|
|
||||||
|
|
||||||
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const spells::Spell * spell) const override;
|
int32_t getEffectLevel(const spells::Spell * spell) const override;
|
||||||
|
|||||||
@@ -782,11 +782,6 @@ int32_t CGHeroInstance::getCasterUnitId() const
|
|||||||
return id.getNum();
|
return id.getNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleHex CGHeroInstance::getCasterPosition() const
|
|
||||||
{
|
|
||||||
return BattleHex::INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool) const
|
int32_t CGHeroInstance::getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
int32_t skill = -1; //skill level
|
int32_t skill = -1; //skill level
|
||||||
|
|||||||
@@ -279,7 +279,6 @@ public:
|
|||||||
|
|
||||||
///spells::Caster
|
///spells::Caster
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
BattleHex getCasterPosition() const override;
|
|
||||||
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const spells::Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
int64_t getSpellBonus(const spells::Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
||||||
int64_t getSpecificSpellBonus(const spells::Spell * spell, int64_t base) const override;
|
int64_t getSpecificSpellBonus(const spells::Spell * spell, int64_t base) const override;
|
||||||
|
|||||||
@@ -223,8 +223,9 @@ bool BattleSpellMechanics::canCastAtTarget(const battle::Unit * target) const
|
|||||||
if(range <= 0)
|
if(range <= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
std::vector<BattleHex> casterPos = { caster->getCasterPosition() };
|
auto casterStack = battle()->battleGetStackByID(caster->getCasterUnitId(), false);
|
||||||
BattleHex casterWidePos = battle()->battleGetStackByID(caster->getCasterUnitId(), false)->occupiedHex();
|
std::vector<BattleHex> casterPos = { casterStack->getPosition() };
|
||||||
|
BattleHex casterWidePos = casterStack->occupiedHex();
|
||||||
if(casterWidePos != BattleHex::INVALID)
|
if(casterWidePos != BattleHex::INVALID)
|
||||||
casterPos.push_back(casterWidePos);
|
casterPos.push_back(casterWidePos);
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,6 @@ int32_t ProxyCaster::getCasterUnitId() const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleHex ProxyCaster::getCasterPosition() const
|
|
||||||
{
|
|
||||||
if(actualCaster)
|
|
||||||
return actualCaster->getCasterPosition();
|
|
||||||
|
|
||||||
return BattleHex::INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
int32_t ProxyCaster::getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
if(actualCaster)
|
if(actualCaster)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public:
|
|||||||
virtual ~ProxyCaster();
|
virtual ~ProxyCaster();
|
||||||
|
|
||||||
int32_t getCasterUnitId() const override;
|
int32_t getCasterUnitId() const override;
|
||||||
BattleHex getCasterPosition() const override;
|
|
||||||
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
int32_t getSpellSchoolLevel(const Spell * spell, SpellSchool * outSelectedSchool = nullptr) const override;
|
||||||
int32_t getEffectLevel(const Spell * spell) const override;
|
int32_t getEffectLevel(const Spell * spell) const override;
|
||||||
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const override;
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ public:
|
|||||||
MOCK_CONST_METHOD0(getTreeVersion, int32_t());
|
MOCK_CONST_METHOD0(getTreeVersion, int32_t());
|
||||||
|
|
||||||
MOCK_CONST_METHOD0(getCasterUnitId, int32_t());
|
MOCK_CONST_METHOD0(getCasterUnitId, int32_t());
|
||||||
MOCK_CONST_METHOD0(getCasterPosition, BattleHex());
|
|
||||||
MOCK_CONST_METHOD2(getSpellSchoolLevel, int32_t(const spells::Spell *, SpellSchool *));
|
MOCK_CONST_METHOD2(getSpellSchoolLevel, int32_t(const spells::Spell *, SpellSchool *));
|
||||||
MOCK_CONST_METHOD1(getEffectLevel, int32_t(const spells::Spell *));
|
MOCK_CONST_METHOD1(getEffectLevel, int32_t(const spells::Spell *));
|
||||||
MOCK_CONST_METHOD3(getSpellBonus, int64_t(const spells::Spell *, int64_t, const battle::Unit *));
|
MOCK_CONST_METHOD3(getSpellBonus, int64_t(const spells::Spell *, int64_t, const battle::Unit *));
|
||||||
|
|||||||
Reference in New Issue
Block a user