From 83baecd8a5f35d2ada3015df6950ced938435698 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Mon, 2 Sep 2024 17:52:06 +0300 Subject: [PATCH] Better stat-related check for buildings - #12180 --- core/src/com/unciv/models/ruleset/Building.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 4cde6fbf55..2e6c7017c5 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -498,10 +498,16 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { } } - fun isStatRelated(stat: Stat): Boolean { - if (get(stat) > 0) return true - if (getStatPercentageBonuses(null)[stat] > 0) return true - if (getMatchingUniques(UniqueType.Stats).any { it.stats[stat] > 0 }) return true + fun isStatRelated(stat: Stat, city: City? = null): Boolean { + if (city != null) { + if (getStats(city)[stat] > 0) return true + if (getStatPercentageBonuses(city)[stat] > 0) return true + } + else { + if (get(stat) > 0) return true + if (getMatchingUniques(UniqueType.Stats).any { it.stats[stat] > 0 }) return true + if (getStatPercentageBonuses(null)[stat] > 0) return true + } if (getMatchingUniques(UniqueType.StatsFromTiles).any { it.stats[stat] > 0 }) return true if (getMatchingUniques(UniqueType.StatsPerPopulation).any { it.stats[stat] > 0 }) return true if (stat == Stat.Happiness && hasUnique(UniqueType.RemoveAnnexUnhappiness)) return true