Fixed bug that occured when city was being razed and managed to reach -1 population somehow

This commit is contained in:
Yair Morgenstern 2018-08-27 12:41:16 +03:00
parent 94e9098ac0
commit c5e4a75505
2 changed files with 7 additions and 3 deletions

View File

@ -161,7 +161,7 @@ class CityInfo {
expansion.nextTurn(stats.culture)
if(isBeingRazed){
population.population--
if(population.population==0){
if(population.population<=0){ // there are strange cases where we geet to -1
civInfo.addNotification("$name {has been razed to the ground}!",location, Color.RED)
destroyCity()
if(isCapital() && civInfo.cities.isNotEmpty()) // Yes, we actually razed the capital. Some people do this.
@ -170,8 +170,10 @@ class CityInfo {
}
else population.nextTurn(stats.food)
health = min(health+20, getMaxHealth())
population.unassignExtraPopulation()
if(this in civInfo.cities) { // city was not destroyed
health = min(health + 20, getMaxHealth())
population.unassignExtraPopulation()
}
}
fun destroyCity() {

View File

@ -131,6 +131,8 @@ class CityStats {
val happinessFromBuildings = cityInfo.cityConstructions.getStats().happiness.toInt().toFloat()
newHappinessList ["Buildings"] = happinessFromBuildings
// we don't want to modify the existing happiness list because that leads
// to concurrency problems if we iterate on it while changing
happinessList=newHappinessList
return newHappinessList
}