When removing a terrain (e.g. Forest) whose improvement depends on it (e.g. Lumber mill), the improvement is removed

This commit is contained in:
Yair Morgenstern 2018-07-16 09:17:42 +03:00
parent 6ca586c3b1
commit 43ef42be5f

View file

@ -77,7 +77,16 @@ class MapUnit {
tile.turnsToImprovement -= 1
if (tile.turnsToImprovement != 0) return
when {
tile.improvementInProgress!!.startsWith("Remove") -> tile.terrainFeature = null
tile.improvementInProgress!!.startsWith("Remove") -> {
val tileImprovement = tile.tileImprovement
if(tileImprovement!=null
&& tileImprovement.terrainsCanBeBuiltOn.contains(tile.terrainFeature)
&& !tileImprovement.terrainsCanBeBuiltOn.contains(tile.baseTerrain)) {
tile.improvement = null // We removed a terrain (e.g. Forest) and the improvement (e.g. Lumber mill) requires it!
}
tile.terrainFeature = null
}
tile.improvementInProgress == "Road" -> tile.roadStatus = RoadStatus.Road
tile.improvementInProgress == "Railroad" -> tile.roadStatus = RoadStatus.Railroad
else -> tile.improvement = tile.improvementInProgress