When capturing a city, the expansion of that city is reset.

This leaves a situation where previously worked tiles are outside of the new borders, and so the population that was working there needs to be reassigned.
This commit is contained in:
Yair Morgenstern
2018-05-02 08:39:27 +03:00
parent cb381ec82e
commit af8b307782
3 changed files with 8 additions and 3 deletions

View File

@ -131,6 +131,11 @@ class Battle(val gameInfo:GameInfo) {
city.getCenterTile().unit = null
city.expansion.cultureStored = 0;
city.expansion.reset()
// now that the tiles have changed, we need to reassign population
city.workedTiles.filterNot { city.tiles.contains(it) }
.forEach { city.workedTiles.remove(it); city.population.autoAssignPopulation() }
if(city.cityConstructions.isBuilt("Palace")){
city.cityConstructions.builtBuildings.remove("Palace")
if(enemyCiv.cities.isEmpty()) {

View File

@ -100,7 +100,7 @@ class CityInfo {
if (listOf("Forest", "Jungle", "Marsh").contains(tile.terrainFeature))
tile.terrainFeature = null
population.autoAssignWorker()
population.autoAssignPopulation()
cityStats.update()
}

View File

@ -54,12 +54,12 @@ class PopulationManager {
foodStored -= getFoodToNextPopulation()
if (cityInfo.buildingUniques.contains("FoodCarriesOver")) foodStored += (0.4f * getFoodToNextPopulation()).toInt() // Aqueduct special
population++
autoAssignWorker()
autoAssignPopulation()
cityInfo.civInfo.addNotification(cityInfo.name + " has grown!", cityInfo.location)
}
}
internal fun autoAssignWorker() {
internal fun autoAssignPopulation() {
val toWork: TileInfo? = cityInfo.getTiles()
.filterNot { cityInfo.workedTiles.contains(it.position) || cityInfo.location==it.position}
.maxBy { Automation().rankTile(it,cityInfo.civInfo) }