mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-14 02:33:51 +02:00
[programming challenge] Implemented battleGetObstaclesAtTile.
This commit is contained in:
parent
d4056bb034
commit
8e10d315ed
@ -157,10 +157,17 @@ int CBattleInfoCallback::battleGetBattlefieldType()
|
||||
return gs->curB->battlefieldType;
|
||||
}
|
||||
|
||||
int CBattleInfoCallback::battleGetObstaclesAtTile(THex tile) //returns bitfield
|
||||
int CBattleInfoCallback::battleGetObstaclesAtTile(THex tile)
|
||||
{
|
||||
//TODO - write
|
||||
return -1;
|
||||
std::vector<CObstacleInstance> obstacles = battleGetAllObstacles();
|
||||
std::set<THex> coveredHexes;
|
||||
for(int b = 0; b < obstacles.size(); ++b)
|
||||
{
|
||||
std::vector<THex> blocked = VLC->heroh->obstacles.find(obstacles[b].ID)->second.getBlocked(obstacles[b].pos);
|
||||
for(int w = 0; w < blocked.size(); ++w)
|
||||
coveredHexes.insert(blocked[w]);
|
||||
}
|
||||
return vstd::contains(coveredHexes, tile);
|
||||
}
|
||||
|
||||
std::vector<CObstacleInstance> CBattleInfoCallback::battleGetAllObstacles()
|
||||
|
@ -93,7 +93,7 @@ public:
|
||||
|
||||
int battleGetBattlefieldType();
|
||||
|
||||
/// returns bitfield
|
||||
/// returns 1 if there is an obstacle or 0 otherwise
|
||||
int battleGetObstaclesAtTile(THex tile);
|
||||
|
||||
/// returns all obstacles on the battlefield
|
||||
|
Loading…
Reference in New Issue
Block a user