mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 13:49:54 +07:00
When picking random city states for a map, first priority now goes to city states with starting locations defined in the map
This commit is contained in:
@ -41,8 +41,15 @@ class GameStarter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
val cityStatesWithStartingLocations =
|
||||||
|
gameInfo.tileMap.values.filter { it.improvement!=null && it.improvement!!.startsWith("StartingLocation ") }
|
||||||
|
.map { it.improvement!!.replace("StartingLocation ","") }
|
||||||
|
|
||||||
val availableCityStatesNames = Stack<String>()
|
val availableCityStatesNames = Stack<String>()
|
||||||
availableCityStatesNames.addAll(GameBasics.Nations.filter { it.value.isCityState() }.keys.shuffled())
|
// since we shuffle and then order by, we end up with all the city states with starting locations first in a random order,
|
||||||
|
// and then all the other city states in a random order! Because the sortedBy function is stable!
|
||||||
|
availableCityStatesNames.addAll(GameBasics.Nations.filter { it.value.isCityState() }.keys
|
||||||
|
.shuffled().sortedByDescending { it in cityStatesWithStartingLocations })
|
||||||
|
|
||||||
for (cityStateName in availableCityStatesNames.take(newGameParameters.numberOfCityStates)) {
|
for (cityStateName in availableCityStatesNames.take(newGameParameters.numberOfCityStates)) {
|
||||||
val civ = CivilizationInfo(cityStateName)
|
val civ = CivilizationInfo(cityStateName)
|
||||||
|
Reference in New Issue
Block a user