From 2def82c4a6319be4f6445ac5395ca5a21ac3037c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 18 Sep 2019 22:42:44 +0300 Subject: [PATCH] When picking random city states for a map, first priority now goes to city states with starting locations defined in the map --- core/src/com/unciv/logic/GameStarter.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index e86a5787f3..cade63e74c 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -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() - 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)) { val civ = CivilizationInfo(cityStateName)