1
0
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:
Michał W. Urbańczyk 2011-12-12 00:53:27 +00:00
parent d4056bb034
commit 8e10d315ed
2 changed files with 11 additions and 4 deletions

View File

@ -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()

View File

@ -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