From b1d2b13ddd252ee86ddef567aaa20750a12d2002 Mon Sep 17 00:00:00 2001 From: Duan Tao Date: Fri, 14 Dec 2018 16:35:10 +0800 Subject: [PATCH] Improvements. --- core/src/com/unciv/logic/map/TileMap.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/core/src/com/unciv/logic/map/TileMap.kt b/core/src/com/unciv/logic/map/TileMap.kt index 52dfdda2bb..85eeea58eb 100644 --- a/core/src/com/unciv/logic/map/TileMap.kt +++ b/core/src/com/unciv/logic/map/TileMap.kt @@ -75,21 +75,16 @@ class TileMap { val unit = GameBasics.Units[unitName]!!.getMapUnit() val tilesInDistance = getTilesInDistance(position, 2) unit.assignOwner(civInfo) // both the civ name and actual civ need to be in here in order to calculate the canMoveTo...Darn - val unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) && (unit.type.isWaterUnit() || it.isLand()) } + var unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) && (unit.type.isWaterUnit() || it.isLand()) } + if (unitToPlaceTile==null) + unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) } + if(unitToPlaceTile!=null) { //see if a land unit can be placed on land. if impossible, put it on water. // only once we know the unit can be placed do we add it to the civ's unit list unit.putInTile(unitToPlaceTile) unit.currentMovement = unit.getMaxMovement().toFloat() } - else { - val unitToPlaceTile = tilesInDistance.firstOrNull { unit.canMoveTo(it) } - if(unitToPlaceTile!=null) { - // only once we know the unit can be placed do we add it to the civ's unit list - unit.putInTile(unitToPlaceTile) - unit.currentMovement = unit.getMaxMovement().toFloat() - } - else civInfo.removeUnit(unit) // since we added it to the civ units in the previous assignOwner - } + else civInfo.removeUnit(unit) // since we added it to the civ units in the previous assignOwner return unit }