Barbarians now destroy cities instead of capturing them

Destroyed cities reliquish their tiles like they're supposed to
This commit is contained in:
Yair Morgenstern 2018-08-27 12:16:25 +03:00
parent 0d42585ce9
commit 28f5ef5e4f
4 changed files with 18 additions and 7 deletions

View File

@ -17,7 +17,7 @@
name:"China", name:"China",
mainColor:[ 9, 112, 84], mainColor:[ 9, 112, 84],
cities:["Beijing","Shanghai","Guangzhou","Nanjing","Xian","Chengdu","Hangzhou","Tianjin","Macau","Shandong", 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"] "Taiyuan","Tainan","Dalian","Lijiang","Wuxi","Suzhou","Maoming","Shaoguan","Yangjiang","Heyuan"]
}, },
{ {

View File

@ -105,15 +105,22 @@ class Battle(val gameInfo:GameInfo) {
private fun conquerCity(city: CityInfo, attacker: ICombatant) { private fun conquerCity(city: CityInfo, attacker: ICombatant) {
val enemyCiv = city.civInfo val enemyCiv = city.civInfo
attacker.getCivilization().addNotification("We have conquered the city of [${city.name}]!",city.location, Color.RED) 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 { city.getCenterTile().apply {
if(militaryUnit!=null) militaryUnit!!.destroy() if(militaryUnit!=null) militaryUnit!!.destroy()
if(civilianUnit!=null) captureCivilianUnit(attacker,MapUnitCombatant(civilianUnit!!)) 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")){ if(city.cityConstructions.isBuilt("Palace")){
city.cityConstructions.builtBuildings.remove("Palace") city.cityConstructions.builtBuildings.remove("Palace")
if(enemyCiv.isDefeated()) { if(enemyCiv.isDefeated()) {

View File

@ -163,7 +163,7 @@ class CityInfo {
population.population-- population.population--
if(population.population==0){ if(population.population==0){
civInfo.addNotification("$name {has been razed to the ground}!",location, Color.RED) 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. if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this.
civInfo.cities.first().cityConstructions.builtBuildings.add("Palace") civInfo.cities.first().cityConstructions.builtBuildings.add("Palace")
} }
@ -174,6 +174,11 @@ class CityInfo {
population.unassignExtraPopulation() population.unassignExtraPopulation()
} }
fun destroyCity() {
civInfo.cities.remove(this)
getTiles().forEach { expansion.relinquishOwnership(it) }
}
fun moveToCiv(newCivInfo: CivilizationInfo){ fun moveToCiv(newCivInfo: CivilizationInfo){
civInfo.cities.remove(this) civInfo.cities.remove(this)
newCivInfo.cities.add(this) newCivInfo.cities.add(this)

View File

@ -58,7 +58,6 @@ class PopulationManager {
{ {
if(population>1){ if(population>1){
population-- population--
} }
foodStored = 0 foodStored = 0
} }