Remove worked tiles when population starves (dead men work no tiles)

This commit is contained in:
Yair Morgenstern 2018-05-06 11:20:02 +03:00
parent fd5aaaeee1
commit c6e344b16e
2 changed files with 5 additions and 1 deletions

View file

@ -33,7 +33,7 @@ class CityInfo {
fun getCenterTile(): TileInfo = tileMap[location]
fun getTiles(): List<TileInfo> = tiles.map { tileMap[it] }
fun getTilesInRange(): List<TileInfo> = getCenterTile().getTilesInDistance( 3)
fun getTilesInRange(): List<TileInfo> = getCenterTile().getTilesInDistance( 3).filter { civInfo == it.getOwner() }
// Remove resources required by buildings

View file

@ -45,6 +45,10 @@ class PopulationManager {
// starvation!
{
population--
val lowestRankedWorkedTile = cityInfo.workedTiles
.map{cityInfo.tileMap[it]}
.minBy { Automation().rankTile(it,cityInfo.civInfo) }!!
cityInfo.workedTiles.remove(lowestRankedWorkedTile.position)
foodStored = 0
cityInfo.civInfo.addNotification(cityInfo.name + " is starving!", cityInfo.location)
}