Resolved #9874 - free buildings are converted to civ-specific replacements

This commit is contained in:
Yair Morgenstern 2023-08-02 16:01:21 +03:00
parent bbf2f2ff89
commit 5e7f49dac8

View File

@ -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)
}
}