From fcdf6cba5f86c9f01e49032e316fd68594458ad1 Mon Sep 17 00:00:00 2001 From: itanasi <44038014+itanasi@users.noreply.github.com> Date: Sun, 15 Dec 2024 11:54:20 -0800 Subject: [PATCH] Changes to provide Random Order of Civs in sims (#12656) --- core/src/com/unciv/logic/GameStarter.kt | 7 ++++++- core/src/com/unciv/models/metadata/GameParameters.kt | 2 ++ desktop/src/com/unciv/app/desktop/ConsoleLauncher.kt | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/GameStarter.kt b/core/src/com/unciv/logic/GameStarter.kt index faeb24f92f..f56241aa52 100644 --- a/core/src/com/unciv/logic/GameStarter.kt +++ b/core/src/com/unciv/logic/GameStarter.kt @@ -349,7 +349,12 @@ object GameStarter { .map { it.key } .filter { it in usedCivNames } - for (player in chosenPlayers) { + val playersToAdd = if (newGameParameters.shufflePlayerOrder) { + chosenPlayers.toMutableList().apply { shuffle() } + } else { + chosenPlayers + } + for (player in playersToAdd) { val civ = Civilization(player.chosenCiv) when (player.chosenCiv) { in usedMajorCivs, Constants.spectator -> { diff --git a/core/src/com/unciv/models/metadata/GameParameters.kt b/core/src/com/unciv/models/metadata/GameParameters.kt index 429f78fc09..67cdbda847 100644 --- a/core/src/com/unciv/models/metadata/GameParameters.kt +++ b/core/src/com/unciv/models/metadata/GameParameters.kt @@ -31,6 +31,7 @@ class GameParameters : IsPartOfGameInfoSerialization { // Default values are the var nuclearWeaponsEnabled = true var espionageEnabled = false var noStartBias = false + var shufflePlayerOrder = false var victoryTypes: ArrayList = arrayListOf() var startingEra = "Ancient era" @@ -71,6 +72,7 @@ class GameParameters : IsPartOfGameInfoSerialization { // Default values are the parameters.nuclearWeaponsEnabled = nuclearWeaponsEnabled parameters.espionageEnabled = espionageEnabled parameters.noStartBias = noStartBias + parameters.shufflePlayerOrder = shufflePlayerOrder parameters.victoryTypes = ArrayList(victoryTypes) parameters.startingEra = startingEra parameters.isOnlineMultiplayer = isOnlineMultiplayer diff --git a/desktop/src/com/unciv/app/desktop/ConsoleLauncher.kt b/desktop/src/com/unciv/app/desktop/ConsoleLauncher.kt index a751ae3dae..cd10770761 100644 --- a/desktop/src/com/unciv/app/desktop/ConsoleLauncher.kt +++ b/desktop/src/com/unciv/app/desktop/ConsoleLauncher.kt @@ -79,6 +79,7 @@ internal object ConsoleLauncher { numberOfCityStates = 0 speed = Speed.DEFAULT noBarbarians = true + shufflePlayerOrder = true players = ArrayList().apply { civilizations.forEach { add(Player(it)) } add(Player(Constants.spectator, PlayerType.Human))