Fixed : unit cannot be bombarded sometimes between 2 cites. (#1193)

This commit is contained in:
Duan Tao
2019-10-16 01:34:08 +08:00
committed by Yair Morgenstern
parent 6c8c851ea2
commit e6659a80e0

View File

@ -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)
}
}