Resolved #787 - when selecting bombardable enemy unit with no military unit selected, bombarding city is automatically selected

This commit is contained in:
Yair Morgenstern 2019-05-20 20:06:08 +03:00
parent d07e406510
commit 3cfe3a7f73
2 changed files with 14 additions and 1 deletions

View File

@ -16,6 +16,7 @@ import com.unciv.logic.civilization.CivilizationInfo
import com.unciv.logic.map.MapUnit
import com.unciv.logic.map.TileInfo
import com.unciv.logic.map.TileMap
import com.unciv.models.gamebasics.unit.UnitType
import com.unciv.ui.tilegroups.WorldTileGroup
import com.unciv.ui.utils.*
import kotlin.concurrent.thread
@ -84,6 +85,18 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
queueAddMoveHereButton(selectedUnit, tileInfo)
}
if(selectedUnit==null || selectedUnit.type==UnitType.Civilian){
val unitsInTile = selectedTile!!.getUnits()
if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.currentPlayerCiv)){
// 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())
worldScreen.bottomBar.unitTable.citySelected(citiesThatCanBombard.first())
}
}
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
worldScreen.shouldUpdate = true
}

View File

@ -37,7 +37,7 @@ class TradePopup(worldScreen: WorldScreen): PopupTable(worldScreen){
addGoodSizedLabel(translatedNation.tradeRequest).colspan(columns).row()
addButton("Sounds good!".tr()){
addButton("Sounds good!"){
val tradeLogic = TradeLogic(currentPlayerCiv, requestingCiv)
tradeLogic.currentTrade.set(trade)
tradeLogic.acceptTrade()