From 48941fb68e35e6a0283d4c5d6dad8033aceb2732 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Mon, 25 Aug 2025 14:17:02 +0300 Subject: [PATCH] Resolved #13853 - Force rankings doesn't evaluate all unit conditionals as multiplicative --- .../com/unciv/models/ruleset/unit/BaseUnit.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 9acf1f6814..62f0199d2d 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -539,13 +539,18 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { promotions.asSequence() .mapNotNull { ruleset.unitPromotions[it] } .flatMap { it.uniqueObjects } + + // When we have multiple conditional strength bonuses, only the highest one counts + // Otherwise we get massive overvaluation of units with many conflicting conditionals + var highestConditionalPowerBonus = 1f for (unique in allUniques) { when (unique.type) { UniqueType.Strength -> { if (unique.params[0].toInt() <= 0) continue + if (unique.hasModifier(UniqueType.ConditionalVsUnits)) { // Bonus vs some units - a quarter of the bonus - power *= (unique.params[0].toInt() / 4f).toPercent() + highestConditionalPowerBonus = (unique.params[0].toInt() / 4f).toPercent() } else if ( unique.modifiers.any { it.type == UniqueType.ConditionalVsCity // City Attack - half the bonus @@ -554,9 +559,9 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { || it.type == UniqueType.ConditionalFightingInTiles } // Bonus in terrain or feature - half the bonus ) { - power *= (unique.params[0].toInt() / 2f).toPercent() + highestConditionalPowerBonus = (unique.params[0].toInt() / 2f).toPercent() } else { - power *= (unique.params[0].toInt()).toPercent() // Static bonus + highestConditionalPowerBonus = (unique.params[0].toInt()).toPercent() // Static bonus } } UniqueType.StrengthNearCapital -> @@ -564,15 +569,16 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { power *= (unique.params[0].toInt() / 4f).toPercent() // Bonus decreasing with distance from capital - not worth much most of the map??? UniqueType.MayParadrop // Paradrop - 25% bonus - -> power += power / 4 + -> power *= 1.25f UniqueType.MayParadropOld // ParadropOld - 25% bonus - -> power += power / 4 + -> power *= 1.25f UniqueType.MustSetUp // Must set up - 20 % penalty - -> power -= power / 5 + -> power /= 1.20f UniqueType.AdditionalAttacks // Extra attacks - 20% bonus per extra attack - -> power += (power * unique.params[0].toInt()) / 5 + -> power *= (unique.params[0].toInt() * 20f).toPercent() else -> {} } + power *= highestConditionalPowerBonus } return power.toInt()