From 07e3a2228e05ee3762d0adab6413a714d2e1c03b Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Tue, 13 Jul 2021 05:26:37 +0200 Subject: [PATCH] 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 --- android/assets/jsons/Civ V - Vanilla/Buildings.json | 4 ++-- core/src/com/unciv/logic/city/PopulationManager.kt | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/android/assets/jsons/Civ V - Vanilla/Buildings.json b/android/assets/jsons/Civ V - Vanilla/Buildings.json index 9eaa534b0c..4809e17327 100644 --- a/android/assets/jsons/Civ V - Vanilla/Buildings.json +++ b/android/assets/jsons/Civ V - Vanilla/Buildings.json @@ -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", diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index fe240864cf..fa226b187e 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -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++