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",
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"]
},
{

View file

@ -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()) {

View file

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

View file

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