From e6659a80e06a008f4b5dd09e6b4ed34794c41a41 Mon Sep 17 00:00:00 2001 From: Duan Tao Date: Wed, 16 Oct 2019 01:34:08 +0800 Subject: [PATCH] Fixed : unit cannot be bombarded sometimes between 2 cites. (#1193) --- core/src/com/unciv/ui/worldscreen/TileMapHolder.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 831056d1dd..0f8e3924c1 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -101,8 +101,10 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: val unitTable = worldScreen.bottomBar.unitTable val previousSelectedUnit = unitTable.selectedUnit + val previousSelectedCity = unitTable.selectedCity unitTable.tileSelected(tileInfo) val newSelectedUnit = unitTable.selectedUnit + val newSelectedCity = unitTable.selectedCity if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo && worldScreen.isPlayersTurn @@ -115,13 +117,12 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap: if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){ val unitsInTile = selectedTile!!.getUnits() - if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)){ + if(previousSelectedCity != null && !previousSelectedCity.attackedThisTurn + && selectedTile!!.getTilesInDistance(2).contains(previousSelectedCity.ccenterTile) + && unitsInTile.isNotEmpty() + && unitsInTile.first().civInfo.isAtWarWith(worldScreen.viewingCiv)){ // try to select the closest city to bombard this guy - val citiesThatCanBombard = selectedTile!!.getTilesInDistance(2) - .filter { it.isCityCenter() }.map { it.getCity()!! } - .filter { !it.attackedThisTurn } - if(citiesThatCanBombard.isNotEmpty()) - unitTable.citySelected(citiesThatCanBombard.first()) + unitTable.citySelected(previousSelectedCity) } }