From 1b7b9bfcd5c68ea813880407aa287353744526a1 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 5 Jul 2020 23:03:28 +0300 Subject: [PATCH] Civ is properly destroyed when liberating the last city of the civ --- core/src/com/unciv/logic/city/CityInfo.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index a156e15f..3ea5f5fd 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -392,7 +392,6 @@ class CityInfo { moveToCiv(conqueringCiv) Battle.destroyIfDefeated(oldCiv, conqueringCiv) - if(population.population>1) population.population -= 1 + population.population/4 // so from 2-4 population, remove 1, from 5-8, remove 2, etc. reassignPopulation() @@ -439,25 +438,27 @@ class CityInfo { } + val oldCiv = civInfo diplomaticRepercussionsForLiberatingCity(conqueringCiv) val foundingCiv = civInfo.gameInfo.civilizations.first { it.civName == foundingCiv } moveToCiv(foundingCiv) - health = getMaxHealth() / 2 // I think that cities recover to half health when conquered? + Battle.destroyIfDefeated(oldCiv, conqueringCiv) + health = getMaxHealth() / 2 // I think that cities recover to half health when conquered? reassignPopulation() - if(foundingCiv.cities.size == 1) cityConstructions.addBuilding("Palace") // Resurrection! + if (foundingCiv.cities.size == 1) cityConstructions.addBuilding("Palace") // Resurrection! isPuppet = false cityStats.update() // Move units out of the city when liberated - for(unit in getTiles().flatMap { it.getUnits() }.toList()) - if(!unit.movement.canPassThrough(unit.currentTile)) + for (unit in getTiles().flatMap { it.getUnits() }.toList()) + if (!unit.movement.canPassThrough(unit.currentTile)) unit.movement.teleportToClosestMoveableTile() - UncivGame.Current.worldScreen.shouldUpdate=true + UncivGame.Current.worldScreen.shouldUpdate = true } private fun diplomaticRepercussionsForLiberatingCity(conqueringCiv: CivilizationInfo) {