mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-18 03:38:55 +07:00
Fixed : unit cannot be bombarded sometimes between 2 cites. (#1193)
This commit is contained in:

committed by
Yair Morgenstern

parent
6c8c851ea2
commit
e6659a80e0
@ -101,8 +101,10 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomBar.unitTable
|
||||||
val previousSelectedUnit = unitTable.selectedUnit
|
val previousSelectedUnit = unitTable.selectedUnit
|
||||||
|
val previousSelectedCity = unitTable.selectedCity
|
||||||
unitTable.tileSelected(tileInfo)
|
unitTable.tileSelected(tileInfo)
|
||||||
val newSelectedUnit = unitTable.selectedUnit
|
val newSelectedUnit = unitTable.selectedUnit
|
||||||
|
val newSelectedCity = unitTable.selectedCity
|
||||||
|
|
||||||
if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo
|
if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo
|
||||||
&& worldScreen.isPlayersTurn
|
&& worldScreen.isPlayersTurn
|
||||||
@ -115,13 +117,12 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){
|
if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){
|
||||||
val unitsInTile = selectedTile!!.getUnits()
|
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
|
// try to select the closest city to bombard this guy
|
||||||
val citiesThatCanBombard = selectedTile!!.getTilesInDistance(2)
|
unitTable.citySelected(previousSelectedCity)
|
||||||
.filter { it.isCityCenter() }.map { it.getCity()!! }
|
|
||||||
.filter { !it.attackedThisTurn }
|
|
||||||
if(citiesThatCanBombard.isNotEmpty())
|
|
||||||
unitTable.citySelected(citiesThatCanBombard.first())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user