From 48744f658cac6f07327dc466207b60c7f3b58738 Mon Sep 17 00:00:00 2001 From: OptimizedForDensity <105244635+OptimizedForDensity@users.noreply.github.com> Date: Mon, 11 Jul 2022 12:08:19 -0400 Subject: [PATCH] City health updates when finishing health-increasing buildings (#7310) * Set full health if city builds health increasing building while at full health * Proportional health addition * Move function to postBuildEvent function --- core/src/com/unciv/models/ruleset/Building.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/com/unciv/models/ruleset/Building.kt b/core/src/com/unciv/models/ruleset/Building.kt index 580dd6f803..1b6ff30696 100644 --- a/core/src/com/unciv/models/ruleset/Building.kt +++ b/core/src/com/unciv/models/ruleset/Building.kt @@ -661,6 +661,12 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction { return true } + if (cityHealth > 0) { + // city built a building that increases health so add a portion of this added health that is + // proportional to the city's current health + cityConstructions.cityInfo.health += (cityHealth.toFloat() * cityConstructions.cityInfo.health.toFloat() / cityConstructions.cityInfo.getMaxHealth().toFloat()).toInt() + } + cityConstructions.addBuilding(name) /** Support for [UniqueType.CreatesOneImprovement] */