Workers can now remove Roads and Railroads

This commit is contained in:
Yair Morgenstern 2019-05-04 21:55:31 +03:00
parent d527ccf90e
commit d8fd48b4ce
5 changed files with 33 additions and 14 deletions

View File

@ -111,6 +111,16 @@
techRequired:"Bronze Working"
},
// These are unique and have unique in-game checks related to them
{
name:"Remove Road",
turnsToBuild:2
},
{
name:"Remove Railroad",
turnsToBuild:2
},
// Great Person improvements
{
name:"Academy",

View File

@ -3,6 +3,7 @@ package com.unciv.logic
import com.badlogic.gdx.graphics.Color
import com.unciv.GameParameters
import com.unciv.logic.automation.NextTurnAutomation
import com.unciv.logic.city.CityConstructions
import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.civilization.PlayerType
import com.unciv.logic.map.TileInfo
@ -142,18 +143,9 @@ class GameInfo {
}
// As of 2.14.1, changed Machu Pichu to Machu Picchu
val oldMachuName = "Machu Pichu"
val newMachuName = "Machu Picchu"
if(cityConstructions.builtBuildings.contains(oldMachuName)){
cityConstructions.builtBuildings.remove(oldMachuName)
cityConstructions.builtBuildings.add(newMachuName)
}
if (cityConstructions.currentConstruction == oldMachuName)
cityConstructions.currentConstruction = newMachuName
if (cityConstructions.inProgressConstructions.containsKey(oldMachuName)) {
cityConstructions.inProgressConstructions[newMachuName] = cityConstructions.inProgressConstructions[oldMachuName]!!
cityConstructions.inProgressConstructions.remove(oldMachuName)
}
changeBuildingName(cityConstructions, "Machu Pichu", "Machu Picchu")
// As of 2.16.1, changed Colloseum to Colosseum
changeBuildingName(cityConstructions, "Colloseum", "Colosseum")
}
}
@ -163,4 +155,17 @@ class GameInfo {
}
}
private fun changeBuildingName(cityConstructions: CityConstructions, oldBuildingName: String, newBuildingName: String) {
if (cityConstructions.builtBuildings.contains(oldBuildingName)) {
cityConstructions.builtBuildings.remove(oldBuildingName)
cityConstructions.builtBuildings.add(newBuildingName)
}
if (cityConstructions.currentConstruction == oldBuildingName)
cityConstructions.currentConstruction = newBuildingName
if (cityConstructions.inProgressConstructions.containsKey(oldBuildingName)) {
cityConstructions.inProgressConstructions[newBuildingName] = cityConstructions.inProgressConstructions[oldBuildingName]!!
cityConstructions.inProgressConstructions.remove(oldBuildingName)
}
}
}

View File

@ -322,8 +322,9 @@ class MapUnit {
&& !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
if(tile.improvementInProgress=="Remove Road" || tile.improvementInProgress=="Remove Railroad")
tile.roadStatus = RoadStatus.None
else tile.terrainFeature = null
}
tile.improvementInProgress == "Road" -> tile.roadStatus = RoadStatus.Road
tile.improvementInProgress == "Railroad" -> tile.roadStatus = RoadStatus.Railroad

View File

@ -202,6 +202,8 @@ open class TileInfo {
if (improvement.terrainsCanBeBuiltOn.contains(topTerrain!!.name)) return true
if (improvement.name == "Road" && this.roadStatus === RoadStatus.None) return true
if (improvement.name == "Railroad" && this.roadStatus !== RoadStatus.Railroad) return true
if(improvement.name == "Remove Road" && this.roadStatus===RoadStatus.Road) return true
if(improvement.name == "Remove Railroad" && this.roadStatus===RoadStatus.Railroad) return true
if (topTerrain.unbuildable && !(topTerrain.name=="Forest" && improvement.name=="Camp")) return false
return hasViewableResource(civInfo) && getTileResource().improvement == improvement.name

View File

@ -29,6 +29,7 @@ class ImprovementPickerScreen(tileInfo: TileInfo) : PickerScreen() {
val regularImprovements = VerticalGroup()
regularImprovements.space(10f)
for (improvement in GameBasics.TileImprovements.values) {
if (!tileInfo.canBuildImprovement(improvement, currentPlayerCiv)) continue
if(improvement.name == tileInfo.improvement) continue