Better stat-related check for buildings - #12180

This commit is contained in:
yairm210 2024-09-02 17:52:06 +03:00
parent 938cd9008a
commit 83baecd8a5

View File

@ -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