From 28f5ef5e4f8a30133e483202f85d7b2dd0f6ccd3 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 27 Aug 2018 12:16:25 +0300 Subject: [PATCH] Barbarians now destroy cities instead of capturing them Destroyed cities reliquish their tiles like they're supposed to --- android/assets/jsons/Nations.json | 2 +- core/src/com/unciv/logic/battle/Battle.kt | 15 +++++++++++---- core/src/com/unciv/logic/city/CityInfo.kt | 7 ++++++- .../src/com/unciv/logic/city/PopulationManager.kt | 1 - 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/android/assets/jsons/Nations.json b/android/assets/jsons/Nations.json index 2c7ef3ed..949741b4 100644 --- a/android/assets/jsons/Nations.json +++ b/android/assets/jsons/Nations.json @@ -17,7 +17,7 @@ name:"China", mainColor:[ 9, 112, 84], cities:["Beijing","Shanghai","Guangzhou","Nanjing","Xian","Chengdu","Hangzhou","Tianjin","Macau","Shandong", - "Kaifeng","Ningbo","Baoding","Yangzhou","Harbin"m"Chongqing","Luoyang","Kunming","Taipei","Shenyang", + "Kaifeng","Ningbo","Baoding","Yangzhou","Harbin","Chongqing","Luoyang","Kunming","Taipei","Shenyang", "Taiyuan","Tainan","Dalian","Lijiang","Wuxi","Suzhou","Maoming","Shaoguan","Yangjiang","Heyuan"] }, { diff --git a/core/src/com/unciv/logic/battle/Battle.kt b/core/src/com/unciv/logic/battle/Battle.kt index 7075dc3c..d34bc7fa 100644 --- a/core/src/com/unciv/logic/battle/Battle.kt +++ b/core/src/com/unciv/logic/battle/Battle.kt @@ -105,15 +105,22 @@ class Battle(val gameInfo:GameInfo) { private fun conquerCity(city: CityInfo, attacker: ICombatant) { val enemyCiv = city.civInfo attacker.getCivilization().addNotification("We have conquered the city of [${city.name}]!",city.location, Color.RED) - val currentPopulation = city.population.population - if(currentPopulation>1) city.population.population -= 1 + currentPopulation/4 // so from 2-4 population, remove 1, from 5-8, remove 2, etc. - city.moveToCiv(attacker.getCivilization()) - city.health = city.getMaxHealth() / 2 // I think that cities recover to half health when conquered? + city.getCenterTile().apply { if(militaryUnit!=null) militaryUnit!!.destroy() if(civilianUnit!=null) captureCivilianUnit(attacker,MapUnitCombatant(civilianUnit!!)) } + if (attacker.getCivilization().isBarbarianCivilization()){ + city.destroyCity() + } + else { + val currentPopulation = city.population.population + if(currentPopulation>1) city.population.population -= 1 + currentPopulation/4 // so from 2-4 population, remove 1, from 5-8, remove 2, etc. + city.health = city.getMaxHealth() / 2 // I think that cities recover to half health when conquered? + city.moveToCiv(attacker.getCivilization()) + } + if(city.cityConstructions.isBuilt("Palace")){ city.cityConstructions.builtBuildings.remove("Palace") if(enemyCiv.isDefeated()) { diff --git a/core/src/com/unciv/logic/city/CityInfo.kt b/core/src/com/unciv/logic/city/CityInfo.kt index a9244c3d..20814c0d 100644 --- a/core/src/com/unciv/logic/city/CityInfo.kt +++ b/core/src/com/unciv/logic/city/CityInfo.kt @@ -163,7 +163,7 @@ class CityInfo { population.population-- if(population.population==0){ civInfo.addNotification("$name {has been razed to the ground}!",location, Color.RED) - civInfo.cities.remove(this) + destroyCity() if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this. civInfo.cities.first().cityConstructions.builtBuildings.add("Palace") } @@ -174,6 +174,11 @@ class CityInfo { population.unassignExtraPopulation() } + fun destroyCity() { + civInfo.cities.remove(this) + getTiles().forEach { expansion.relinquishOwnership(it) } + } + fun moveToCiv(newCivInfo: CivilizationInfo){ civInfo.cities.remove(this) newCivInfo.cities.add(this) diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index d8068157..fc193d16 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -58,7 +58,6 @@ class PopulationManager { { if(population>1){ population-- - } foodStored = 0 }