Fix election crash (#11731)

* Fixed the election crash

* Added better comments
This commit is contained in:
Oskar Niesen
2024-06-11 10:42:45 -05:00
committed by GitHub
parent 546f7c79a2
commit 96951e21c6
2 changed files with 3 additions and 7 deletions

View File

@ -63,11 +63,6 @@ class CityStateFunctions(val civInfo: Civilization) {
civInfo.cityStateUniqueUnit = possibleUnits.random().name
}
// Set turns to elections to a random number so not every city-state has the same election date
if (civInfo.gameInfo.isEspionageEnabled()) {
civInfo.addFlag(CivFlags.TurnsTillCityStateElection.name, Random.nextInt(civInfo.gameInfo.ruleset.modOptions.constants.cityStateElectionTurns + 1))
}
// TODO: Return false if attempting to put a religious city-state in a game without religion
return true

View File

@ -262,8 +262,9 @@ class TurnManager(val civInfo: Civilization) {
if (civInfo.isCityState()) {
civInfo.questManager.endTurn()
// Todo: Remove this later
// The purpouse of this addition is to migrate the old election system to the new flag system
// Set turns to elections to a random number so not every city-state has the same election date
// May be called at game start or when migrating a game from an older version
if (civInfo.gameInfo.isEspionageEnabled() && !civInfo.hasFlag(CivFlags.TurnsTillCityStateElection.name)) {
civInfo.addFlag(CivFlags.TurnsTillCityStateElection.name, Random.nextInt(civInfo.gameInfo.ruleset.modOptions.constants.cityStateElectionTurns + 1))
}