mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
CBattleInfoEssentials: add battleIsGatePassable()
This is a helper to check if gate is passable now or not.
This commit is contained in:
parent
8397bd91fb
commit
03eb997137
@ -814,11 +814,10 @@ std::vector<std::shared_ptr<const CObstacleInstance>> CBattleInfoCallback::getAl
|
||||
affectedObstacles.push_back(i);
|
||||
}
|
||||
for(auto hex : unit->getHexes())
|
||||
if(hex == ESiegeHex::GATE_BRIDGE)
|
||||
if(battleGetGateState() == EGateState::OPENED || battleGetGateState() == EGateState::DESTROYED)
|
||||
for(int i=0; i<affectedObstacles.size(); i++)
|
||||
if(affectedObstacles.at(i)->obstacleType == CObstacleInstance::MOAT)
|
||||
affectedObstacles.erase(affectedObstacles.begin()+i);
|
||||
if(hex == ESiegeHex::GATE_BRIDGE && battleIsGatePassable())
|
||||
for(int i=0; i<affectedObstacles.size(); i++)
|
||||
if(affectedObstacles.at(i)->obstacleType == CObstacleInstance::MOAT)
|
||||
affectedObstacles.erase(affectedObstacles.begin()+i);
|
||||
}
|
||||
return affectedObstacles;
|
||||
}
|
||||
|
@ -379,6 +379,15 @@ EGateState CBattleInfoEssentials::battleGetGateState() const
|
||||
return getBattle()->getGateState();
|
||||
}
|
||||
|
||||
bool CBattleInfoEssentials::battleIsGatePassable() const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(true);
|
||||
if(battleGetSiegeLevel() == CGTownInstance::NONE)
|
||||
return true;
|
||||
|
||||
return battleGetGateState() == EGateState::OPENED || battleGetGateState() == EGateState::DESTROYED;
|
||||
}
|
||||
|
||||
PlayerColor CBattleInfoEssentials::battleGetOwner(const battle::Unit * unit) const
|
||||
{
|
||||
RETURN_IF_NOT_BATTLE(PlayerColor::CANNOT_DETERMINE);
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
// [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
|
||||
EWallState battleGetWallState(EWallPart partOfWall) const;
|
||||
EGateState battleGetGateState() const;
|
||||
bool battleIsGatePassable() const;
|
||||
|
||||
//helpers
|
||||
///returns all stacks, alive or dead or undead or mechanical :)
|
||||
|
Loading…
x
Reference in New Issue
Block a user