fix: check team when placing tower
This commit is contained in:
@@ -394,14 +394,18 @@ const Color* World::getTileColor(TilePtr tile) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool World::CanPlaceLittleTower(const glm::vec2& worldPos) const {
|
||||
bool World::CanPlaceLittleTower(const glm::vec2& worldPos, PlayerID playerID) const {
|
||||
TilePtr tile = getTile(worldPos.x, worldPos.y);
|
||||
const Player& player = m_Game->getPlayers()[playerID];
|
||||
|
||||
if (tile == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tile->getType() == game::TileType::Tower) {
|
||||
const TowerTile* towerTile = (const TowerTile*) tile.get();
|
||||
if(towerTile->team_owner != player.getTeamColor())
|
||||
return false;
|
||||
for (int x = -1; x < 2; x++) {
|
||||
for (int y = -1; y < 2; y++) {
|
||||
game::TilePtr adjacentTile = getTile(worldPos.x + x, worldPos.y + y);
|
||||
@@ -416,14 +420,18 @@ bool World::CanPlaceLittleTower(const glm::vec2& worldPos) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool World::CanPlaceBigTower(const glm::vec2& worldPos) const {
|
||||
bool World::CanPlaceBigTower(const glm::vec2& worldPos, PlayerID playerID) const {
|
||||
TilePtr tile = getTile(worldPos.x, worldPos.y);
|
||||
const Player& player = m_Game->getPlayers()[playerID];
|
||||
|
||||
if (tile == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tile->getType() == game::TileType::Tower) {
|
||||
const TowerTile* towerTile = (const TowerTile*) tile.get();
|
||||
if(towerTile->team_owner != player.getTeamColor())
|
||||
return false;
|
||||
for (int x = -2; x < 3; x++) {
|
||||
for (int y = -2; y < 3; y++) {
|
||||
game::TilePtr adjacentTile = getTile(worldPos.x + x, worldPos.y + y);
|
||||
|
||||
Reference in New Issue
Block a user