Resolved #4671 - Buildings from era are applied before buildings from policies

This commit is contained in:
Yair Morgenstern 2021-07-29 17:44:18 +03:00
parent 221f45b966
commit 98eba6a995
3 changed files with 31 additions and 26 deletions

View File

@ -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"

View File

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

View File

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