mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 02:40:41 +07:00
If we run outof places to place barbarians at the start of the game, of if we randomly select the same tile twice, the gam wil not crash
This commit is contained in:
@ -31,7 +31,14 @@ class GameStarter(){
|
||||
|
||||
gameInfo.setTransients() // needs to be before placeBarbarianUnit because it depends on the tilemap having its gameinfo set
|
||||
|
||||
(1..5).forEach { gameInfo.placeBarbarianUnit(freeTiles.toList().getRandom()) }
|
||||
(1..5).forEach {
|
||||
val freeTilesList = freeTiles.toList()
|
||||
if(freeTilesList.isNotEmpty()){
|
||||
val placedTile = freeTilesList.getRandom()
|
||||
gameInfo.placeBarbarianUnit(placedTile)
|
||||
freeTiles.remove(placedTile)
|
||||
}
|
||||
}
|
||||
|
||||
return gameInfo
|
||||
}
|
||||
|
Reference in New Issue
Block a user