diff --git a/core/src/com/unciv/logic/civilization/VictoryManager.kt b/core/src/com/unciv/logic/civilization/VictoryManager.kt index deac60a261..568895980c 100644 --- a/core/src/com/unciv/logic/civilization/VictoryManager.kt +++ b/core/src/com/unciv/logic/civilization/VictoryManager.kt @@ -28,7 +28,7 @@ class VictoryManager { } return results } - + private fun votesNeededForDiplomaticVictory(): Int { val civCount = civInfo.gameInfo.civilizations.count { !it.isDefeated() } @@ -38,24 +38,24 @@ class VictoryManager { else (67 - 1.1 * civCount) / 100 * civCount ).toInt() } - + fun hasEnoughVotesForDiplomaticVictory(): Boolean { val results = calculateDiplomaticVotingResults(civInfo.gameInfo.diplomaticVictoryVotesCast) val bestCiv = results.maxByOrNull { it.value } ?: return false - + // If we don't have the highest score, we have not won anyway if (bestCiv.key != civInfo.civName) return false - + // If we don't have enough votes, we haven't won if (bestCiv.value < votesNeededForDiplomaticVictory()) return false - + // If there's a tie, we haven't won either - return (results.none { it != bestCiv && it.value == bestCiv.value }) + return (results.none { it != bestCiv && it.value == bestCiv.value }) } - + fun getVictoryTypeAchieved(): String? { if (!civInfo.isMajorCiv()) return null - for (victoryName in civInfo.gameInfo.ruleSet.victories.keys.filter { it != Constants.neutralVictoryType}) { + for (victoryName in civInfo.gameInfo.gameParameters.victoryTypes.filter { it != Constants.neutralVictoryType}) { if (getNextMilestone(victoryName) == null) return victoryName } @@ -63,7 +63,7 @@ class VictoryManager { return Constants.neutralVictoryType return null } - + fun getNextMilestone(victory: String): Milestone? { for (milestone in civInfo.gameInfo.ruleSet.victories[victory]!!.milestoneObjects) { if (!milestone.hasBeenCompletedBy(civInfo)) @@ -71,7 +71,7 @@ class VictoryManager { } return null } - + fun amountMilestonesCompleted(victory: String): Int { var completed = 0 for (milestone in civInfo.gameInfo.ruleSet.victories[victory]!!.milestoneObjects) { @@ -84,4 +84,4 @@ class VictoryManager { } fun hasWon() = getVictoryTypeAchieved() != null -} \ No newline at end of file +} diff --git a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt index 7c9475f13c..825afc3874 100644 --- a/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt +++ b/core/src/com/unciv/ui/newgamescreen/NewGameScreen.kt @@ -57,6 +57,9 @@ class NewGameScreen( updateRuleset() // must come before playerPickerTable so mod nations from fromSettings // Has to be initialized before the mapOptionsTable, since the mapOptionsTable refers to it on init + // remove the victory types which are not in the rule set (e.g. were in the recently disabled mod) + gameSetupInfo.gameParameters.victoryTypes.removeAll { it !in ruleset.victories.keys } + if (gameSetupInfo.gameParameters.victoryTypes.isEmpty()) gameSetupInfo.gameParameters.victoryTypes.addAll(ruleset.victories.keys)