From 98eba6a995826d6e4cfa1c02dfc822e86908a7d9 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 29 Jul 2021 17:44:18 +0300 Subject: [PATCH] Resolved #4671 - Buildings from era are applied before buildings from policies --- buildSrc/src/main/kotlin/BuildConfig.kt | 4 +- core/src/com/unciv/logic/battle/Battle.kt | 4 +- core/src/com/unciv/logic/city/CityInfo.kt | 49 +++++++++++++---------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/buildSrc/src/main/kotlin/BuildConfig.kt b/buildSrc/src/main/kotlin/BuildConfig.kt index 8915ed23e3..c4e2526b87 100644 --- a/buildSrc/src/main/kotlin/BuildConfig.kt +++ b/buildSrc/src/main/kotlin/BuildConfig.kt @@ -3,8 +3,8 @@ package com.unciv.build object BuildConfig { const val kotlinVersion = "1.4.30" const val appName = "Unciv" - const val appCodeNumber = 597 - const val appVersion = "3.15.15" + const val appCodeNumber = 598 + const val appVersion = "3.15.16" const val gdxVersion = "1.10.0" const val roboVMVersion = "2.3.1" diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index eeb10ab565..f775f33daf 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -504,9 +504,7 @@ object Battle { } // Instead of postBattleAction() just destroy the unit, all other functions are not relevant - if (attacker.unit.hasUnique("Self-destructs when attacking")) { - attacker.unit.destroy() - } + if (attacker.unit.hasUnique("Self-destructs when attacking")) attacker.unit.destroy() // It's unclear whether using nukes results in a penalty with all civs, or only affected civs. // For now I'll make it give a diplomatic penalty to all known civs, but some testing for this would be appreciated diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index 6a8d07a213..9bbd2471c3 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -86,28 +86,10 @@ class CityInfo { civInfo.cities = civInfo.cities.toMutableList().apply { add(this@CityInfo) } - if (civInfo.cities.size == 1) cityConstructions.addBuilding(capitalCityIndicator()) - - civInfo.policies.tryToAddPolicyBuildings() - - for (unique in civInfo.getMatchingUniques("Gain a free [] []")) { - val freeBuildingName = unique.params[0] - if (matchesFilter(unique.params[1])) { - if (!cityConstructions.isBuilt(freeBuildingName)) - cityConstructions.addBuilding(freeBuildingName) - } - } - - // Add buildings and pop we get from starting in this era - val ruleset = civInfo.gameInfo.ruleSet val startingEra = civInfo.gameInfo.gameParameters.startingEra - if (startingEra in ruleset.eras) { - for (building in ruleset.eras[startingEra]!!.settlerBuildings) { - if (ruleset.buildings[building]!!.isBuildable(cityConstructions)) { - cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name) - } - } - } + + addStartingBuildings(civInfo, startingEra) + expansion.reset() @@ -121,6 +103,7 @@ class CityInfo { tile.improvement = null tile.improvementInProgress = null + val ruleset = civInfo.gameInfo.ruleSet workedTiles = hashSetOf() //reassign 1st working tile if (startingEra in ruleset.eras) population.setPopulation(ruleset.eras[startingEra]!!.settlerPopulation) @@ -130,6 +113,30 @@ class CityInfo { triggerCitiesSettledNearOtherCiv() } + private fun addStartingBuildings(civInfo: CivilizationInfo, startingEra: String) { + val ruleset = civInfo.gameInfo.ruleSet + if (civInfo.cities.size == 1) cityConstructions.addBuilding(capitalCityIndicator()) + + // Add buildings and pop we get from starting in this era + if (startingEra in ruleset.eras) { + for (building in ruleset.eras[startingEra]!!.settlerBuildings) { + if (ruleset.buildings[building]!!.isBuildable(cityConstructions)) { + cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name) + } + } + } + + civInfo.policies.tryToAddPolicyBuildings() + + for (unique in civInfo.getMatchingUniques("Gain a free [] []")) { + val freeBuildingName = unique.params[0] + if (matchesFilter(unique.params[1])) { + if (!cityConstructions.isBuilt(freeBuildingName)) + cityConstructions.addBuilding(freeBuildingName) + } + } + } + private fun setNewCityName(civInfo: CivilizationInfo) { val nationCities = civInfo.nation.cities val cityNameIndex = civInfo.citiesCreated % nationCities.size