mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Move isMeleeAttacker to Unit
This commit is contained in:
@@ -545,22 +545,6 @@ bool CUnitState::isShooter() const
|
|||||||
return shots.total() > 0;
|
return shots.total() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUnitState::isMeleeAttacker() const
|
|
||||||
{
|
|
||||||
//exclude non melee attackers
|
|
||||||
static const std::set<CreatureID> nonMeleeAttackers{
|
|
||||||
CreatureID::FIRST_AID_TENT,
|
|
||||||
CreatureID::CATAPULT,
|
|
||||||
CreatureID::BALLISTA,
|
|
||||||
CreatureID::AMMO_CART,
|
|
||||||
CreatureID::ARROW_TOWERS
|
|
||||||
};
|
|
||||||
if (vstd::contains(nonMeleeAttackers, creatureId()))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t CUnitState::getKilled() const
|
int32_t CUnitState::getKilled() const
|
||||||
{
|
{
|
||||||
int32_t res = unitBaseAmount() - health.getCount() + health.getResurrected();
|
int32_t res = unitBaseAmount() - health.getCount() + health.getResurrected();
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ public:
|
|||||||
bool canShootBlocked() const override;
|
bool canShootBlocked() const override;
|
||||||
bool canShoot() const override;
|
bool canShoot() const override;
|
||||||
bool isShooter() const override;
|
bool isShooter() const override;
|
||||||
bool isMeleeAttacker() const override;
|
|
||||||
|
|
||||||
int32_t getKilled() const override;
|
int32_t getKilled() const override;
|
||||||
int32_t getCount() const override;
|
int32_t getCount() const override;
|
||||||
|
|||||||
@@ -38,6 +38,22 @@ bool Unit::isTurret() const
|
|||||||
return creatureIndex() == CreatureID::ARROW_TOWERS;
|
return creatureIndex() == CreatureID::ARROW_TOWERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Unit::isMeleeAttacker() const
|
||||||
|
{
|
||||||
|
//exclude non melee attackers
|
||||||
|
static const std::set<CreatureID> nonMeleeAttackers{
|
||||||
|
CreatureID::FIRST_AID_TENT,
|
||||||
|
CreatureID::CATAPULT,
|
||||||
|
CreatureID::BALLISTA,
|
||||||
|
CreatureID::AMMO_CART,
|
||||||
|
CreatureID::ARROW_TOWERS
|
||||||
|
};
|
||||||
|
if (vstd::contains(nonMeleeAttackers, creatureId()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::string Unit::getDescription() const
|
std::string Unit::getDescription() const
|
||||||
{
|
{
|
||||||
boost::format fmt("Unit %d of side %d");
|
boost::format fmt("Unit %d of side %d");
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public:
|
|||||||
virtual bool canShootBlocked() const = 0;
|
virtual bool canShootBlocked() const = 0;
|
||||||
virtual bool canShoot() const = 0;
|
virtual bool canShoot() const = 0;
|
||||||
virtual bool isShooter() const = 0;
|
virtual bool isShooter() const = 0;
|
||||||
virtual bool isMeleeAttacker() const = 0;
|
bool isMeleeAttacker() const;
|
||||||
|
|
||||||
/// returns initial size of this unit
|
/// returns initial size of this unit
|
||||||
virtual int32_t getCount() const = 0;
|
virtual int32_t getCount() const = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user