From 5e7f49dac86d949e98e230aee5ff8f38729ee5f0 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 2 Aug 2023 16:01:21 +0300 Subject: [PATCH] Resolved #9874 - free buildings are converted to civ-specific replacements --- .../logic/civilization/CivConstructions.kt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/logic/civilization/CivConstructions.kt b/core/src/com/unciv/logic/civilization/CivConstructions.kt index cb49161a2d..be560a6636 100644 --- a/core/src/com/unciv/logic/civilization/CivConstructions.kt +++ b/core/src/com/unciv/logic/civilization/CivConstructions.kt @@ -104,21 +104,24 @@ class CivConstructions : IsPartOfGameInfoSerialization { .mapValues { unique -> unique.value.sumOf { it.params[1].toInt() } } for ((building, amount) in buildingsUniquesData) { - addFreeBuildings(building, amount) + val civBuildingEquivalent = civInfo.getEquivalentBuilding(building) + addFreeBuildings(civBuildingEquivalent, amount) } } - private fun addFreeBuildings(building: String, amount: Int) { + private fun addFreeBuildings(building: Building, amount: Int) { + for (city in civInfo.cities.take(amount)) { - if (freeSpecificBuildingsProvided[building]?.contains(city.id) == true || city.cityConstructions.containsBuildingOrEquivalent(building)) continue + if (freeSpecificBuildingsProvided[building.name]?.contains(city.id) == true + || city.cityConstructions.containsBuildingOrEquivalent(building.name)) continue - (city.cityConstructions.getConstruction(building) as INonPerpetualConstruction).postBuildEvent(city.cityConstructions) + building.postBuildEvent(city.cityConstructions) - if (!freeSpecificBuildingsProvided.containsKey(building)) - freeSpecificBuildingsProvided[building] = hashSetOf() - freeSpecificBuildingsProvided[building]!!.add(city.id) + if (!freeSpecificBuildingsProvided.containsKey(building.name)) + freeSpecificBuildingsProvided[building.name] = hashSetOf() + freeSpecificBuildingsProvided[building.name]!!.add(city.id) - addFreeBuilding(city.id, building) + addFreeBuilding(city.id, building.name) } }