Water units can enter cities

This commit is contained in:
Yair Morgenstern 2018-12-19 19:36:18 +02:00
parent f19750409d
commit a677850084
3 changed files with 8 additions and 3 deletions

View File

@ -192,6 +192,12 @@ class CityInfo {
}
fun destroyCity() {
// Edge case! What if a water unit is in a city, and you raze the city?
// Well, the water unit has to return to the water!
for(unit in getCenterTile().getUnits())
if(!unit.canPassThrough(getCenterTile()))
unit.movementAlgs().teleportToClosestMoveableTile()
civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) }
getTiles().forEach { expansion.relinquishOwnership(it) }
getCenterTile().improvement="City ruins"

View File

@ -134,7 +134,7 @@ class MapUnit {
val tileOwner = tile.getOwner()
if(tile.getBaseTerrain().impassable) return false
if(tile.isLand() && type.isWaterUnit())
if(tile.isLand() && type.isWaterUnit() && !tile.isCityCenter())
return false
val isOcean = tile.baseTerrain == "Ocean"

View File

@ -7,8 +7,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
private fun getMovementCostBetweenAdjacentTiles(from: TileInfo, to: TileInfo): Float {
if(from.isLand() && to.isWater()
|| from.isWater() && to.isLand())
if(unit.type.isLandUnit() && (from.isLand() != to.isLand()))
return 100f // this is embarkment or disembarkment, and will take the entire turn
if (from.roadStatus === RoadStatus.Railroad && to.roadStatus === RoadStatus.Railroad)