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
This commit is contained in:
OptimizedForDensity
2022-07-11 12:08:19 -04:00
committed by GitHub
parent 23026202ec
commit 48744f658c

View File

@ -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] */