Barbarians will not spawn in tiles that any civilization can currently see
This commit is contained in:
parent
ce7cb2ce17
commit
2cd3347cec
1 changed files with 4 additions and 2 deletions
|
@ -64,8 +64,10 @@ class GameInfo {
|
|||
fun placeBarbarianUnit(tileToPlace: TileInfo?) {
|
||||
var tile = tileToPlace
|
||||
if(tileToPlace==null) {
|
||||
val playerViewableTiles = getPlayerCivilization().getViewableTiles().toHashSet()
|
||||
val viableTiles = tileMap.values.filterNot { playerViewableTiles.contains(it) || it.militaryUnit != null || it.civilianUnit!=null}
|
||||
// Barbarians will only spawn in places that no one can see
|
||||
val allViewableTiles = civilizations.filterNot { it.isBarbarianCivilization() }
|
||||
.flatMap { it.getViewableTiles() }.toHashSet()
|
||||
val viableTiles = tileMap.values.filterNot { allViewableTiles.contains(it) || it.militaryUnit != null || it.civilianUnit!=null}
|
||||
if(viableTiles.isEmpty()) return // no place for more barbs =(
|
||||
tile=viableTiles.getRandom()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue