From 5324eb96b5c6ddb5a3af8651d768afc8c14f7a26 Mon Sep 17 00:00:00 2001 From: Xander Lenstra <71121390+xlenstra@users.noreply.github.com> Date: Sat, 31 Jul 2021 22:46:18 +0200 Subject: [PATCH] Fixed bug where production from cutting down forests could apply to perpetual constructions (#4694) --- core/src/com/unciv/logic/city/CityConstructions.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityConstructions.kt b/core/src/com/unciv/logic/city/CityConstructions.kt index d561d8252c..458a21628c 100644 --- a/core/src/com/unciv/logic/city/CityConstructions.kt +++ b/core/src/com/unciv/logic/city/CityConstructions.kt @@ -24,7 +24,7 @@ import kotlin.math.roundToInt * City constructions manager. * * @property cityInfo the city it refers to - * @property currentConstructionFromQueue the name of the construction is currently worked, default = "Monument" + * @property currentConstructionFromQueue the name of the construction is currently worked * @property currentConstructionIsUserSet a flag indicating if the [currentConstructionFromQueue] has been set by the user or by the AI * @property constructionQueue a list of constructions names enqueued */ @@ -100,8 +100,7 @@ class CityConstructions { // all non-local uniques with this placeholderText from other cities belong to wonders, // while the local uniques with this placeholderText are from buildings, but this is in no // way a given. In reality, there should be functions getBuildingStats and getWonderStats, - // to solve this, with getStats merely adding these two together. Implementing this is on - // my ToDoList, but this PR is already large enough as it is. + // to solve this, with getStats merely adding these two together. for (unique in cityInfo.getLocalMatchingUniques("[] per [] population []") .filter { cityInfo.matchesFilter(it.params[2])} ) { @@ -215,7 +214,7 @@ class CityConstructions { // if the construction name is the same as the current construction, it isn't the first return constructionQueueIndex == constructionQueue.indexOfFirst { it == name } } - + internal fun getConstruction(constructionName: String): IConstruction { val gameBasics = cityInfo.getRuleset() @@ -297,6 +296,11 @@ class CityConstructions { } fun addProductionPoints(productionToAdd: Int) { + val construction = getConstruction(currentConstructionFromQueue) + if (construction is PerpetualConstruction) { + productionOverflow += productionToAdd + return + } if (!inProgressConstructions.containsKey(currentConstructionFromQueue)) inProgressConstructions[currentConstructionFromQueue] = 0 inProgressConstructions[currentConstructionFromQueue] = inProgressConstructions[currentConstructionFromQueue]!! + productionToAdd