From b5c44e3a22051aa73e2b80039e70cf3a9e6efede Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Tue, 16 Sep 2025 20:57:45 -0400 Subject: [PATCH] BNW: Update logic around Cultural Victories --- core/src/com/unciv/models/ruleset/Victory.kt | 24 ++++++++----------- .../VictoryScreenIllustrations.kt | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Victory.kt b/core/src/com/unciv/models/ruleset/Victory.kt index eb0e191458..1e2989516a 100644 --- a/core/src/com/unciv/models/ruleset/Victory.kt +++ b/core/src/com/unciv/models/ruleset/Victory.kt @@ -115,7 +115,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor * Gets the percentage progress of one civilization's countable against another's countable. * * @return The progress percentage (0-100). When the result is >100, it qualifies as "more than". - * @see getMoreCountableThanOtherCivRelevent() + * @see getMoreCountableThanOtherCivRelevant() */ @Readonly fun getMoreCountableThanOtherCivPercent(civ: Civilization, otherCiv: Civilization): Float { @@ -134,7 +134,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor * @see getMoreCountableThanOtherCivPercent() */ @Readonly - fun getMoreCountableThanOtherCivRelevent(civ: Civilization, otherCiv: Civilization): Boolean = + fun getMoreCountableThanOtherCivRelevant(civ: Civilization, otherCiv: Civilization): Boolean = civ != otherCiv && otherCiv.isMajorCiv() && otherCiv.isAlive() @Readonly @@ -151,11 +151,10 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor originalMajorCapitalsOwned(civInfo) == civsWithPotentialCapitalsToOwn(civInfo.gameInfo).size MilestoneType.CompletePolicyBranches -> civInfo.policies.completedBranches.size >= params[0].toInt() - MilestoneType.MoreCountableThanEachPlayer -> - civInfo.gameInfo.civilizations.filter { - getMoreCountableThanOtherCivRelevent(civInfo, it) && - getMoreCountableThanOtherCivPercent(civInfo, it) > 100f - }.isNotEmpty() + MilestoneType.MoreCountableThanEachPlayer -> { + val relevantCivs = civInfo.gameInfo.civilizations.filter { getMoreCountableThanOtherCivRelevant(civInfo, it) } + relevantCivs.isNotEmpty() && relevantCivs.all { getMoreCountableThanOtherCivPercent(civInfo, it) > 100f } + } MilestoneType.BuildingBuiltGlobally -> civInfo.gameInfo.getCities().any { it.cityConstructions.isBuilt(params[0]) } @@ -218,12 +217,9 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor "{$uniqueDescription} (${amountDone.tr()}/${amountToDo.tr()})" } MilestoneType.MoreCountableThanEachPlayer -> { - var amountToDo = 0; var amountDone = 0; - for (otherCiv in civInfo.gameInfo.civilizations) { - if (!getMoreCountableThanOtherCivRelevent(civInfo, otherCiv)) continue - amountToDo++ - if (getMoreCountableThanOtherCivPercent(civInfo, otherCiv) > 100f) amountDone++ - } + val relevantCivs = civInfo.gameInfo.civilizations.filter { getMoreCountableThanOtherCivRelevant(civInfo, it) } + val amountToDo = relevantCivs.size + val amountDone = relevantCivs.count { getMoreCountableThanOtherCivPercent(civInfo, it) > 100f } if (civInfo.shouldHideCivCount()) "{$uniqueDescription} (${amountDone.tr()}/?)" else @@ -337,7 +333,7 @@ class Milestone(val uniqueDescription: String, private val parentVictory: Victor MilestoneType.MoreCountableThanEachPlayer -> { val hideCivCount = civInfo.shouldHideCivCount() for (otherCiv in civInfo.gameInfo.civilizations) { - if (!getMoreCountableThanOtherCivRelevent(civInfo, otherCiv)) continue + if (!getMoreCountableThanOtherCivRelevant(civInfo, otherCiv)) continue if (hideCivCount && !civInfo.knows(otherCiv)) continue val civName = if (civInfo.knows(otherCiv)) otherCiv.civName else Constants.unknownNationName val percent = getMoreCountableThanOtherCivPercent(civInfo, otherCiv) diff --git a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenIllustrations.kt b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenIllustrations.kt index 877a11e408..013fbbdbec 100644 --- a/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenIllustrations.kt +++ b/core/src/com/unciv/ui/screens/victoryscreen/VictoryScreenIllustrations.kt @@ -248,7 +248,7 @@ class VictoryScreenIllustrations( MilestoneType.MoreCountableThanEachPlayer -> { var amountDone = 0; var amountToDo = 0; for (otherCiv in civ.gameInfo.civilizations) { - if (!milestone.getMoreCountableThanOtherCivRelevent(civ, otherCiv)) continue + if (!milestone.getMoreCountableThanOtherCivRelevant(civ, otherCiv)) continue amountToDo++ if (milestone.getMoreCountableThanOtherCivPercent(civ, otherCiv) > 100f) amountDone++ }