Fixed bug where effects of all aquaducts nationwide stacked in each city (#4487)

* Fixed bug where effects of all aquaducts nationwide stacked in each city

* Implemented requested changes

* Implemented requested changes better
This commit is contained in:
Xander Lenstra 2021-07-13 05:26:37 +02:00 committed by GitHub
parent 573eacb8c9
commit 07e3a2228e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -393,7 +393,7 @@
"name": "Aqueduct",
"maintenance": 1,
"hurryCostModifier": 0,
"uniques": ["[40]% of food is carried over after population increases"],
"uniques": ["[40]% of food is carried over [in this city] after population increases"],
"requiredTech": "Engineering"
},
{
@ -978,7 +978,7 @@
"requiredBuilding": "Hospital",
"maintenance": 3,
"requiredTech": "Pharmaceuticals",
"uniques": ["[25]% of food is carried over after population increases"]
"uniques": ["[25]% of food is carried over [in this city] after population increases"]
},
{
"name": "Manhattan Project",

View File

@ -60,9 +60,15 @@ class PopulationManager {
if (foodStored >= getFoodToNextPopulation()) { // growth!
foodStored -= getFoodToNextPopulation()
var percentOfFoodCarriedOver = cityInfo
.getMatchingUniques("[]% of food is carried over after population increases")
.getMatchingUniques("[]% of food is carried over [] after population increases")
.filter { cityInfo.matchesFilter(it.params[1]) }
.sumBy { it.params[0].toInt() }
// Deprecated since 3.15.11
percentOfFoodCarriedOver += cityInfo
.getLocalMatchingUniques("[]% of food is carried over after population increases")
.sumBy { it.params[0].toInt() }
// Try to avoid runaway food gain in mods, just in case mod makes don't notice it
//
// Try to avoid runaway food gain in mods, just in case
if (percentOfFoodCarriedOver > 95) percentOfFoodCarriedOver = 95
foodStored += (getFoodToNextPopulation() * percentOfFoodCarriedOver / 100f).toInt()
population++