From 8798f02217a619441ef70c20f222fa7ca44dd36c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Mon, 9 Apr 2018 12:54:33 +0300 Subject: [PATCH] Select next idle is no longer enables if an ENEMY unit is idle --- core/src/com/unciv/ui/worldscreen/unit/IdleUnitButton.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/unit/IdleUnitButton.kt b/core/src/com/unciv/ui/worldscreen/unit/IdleUnitButton.kt index f17df3cf3b..a404433ad3 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/IdleUnitButton.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/IdleUnitButton.kt @@ -9,9 +9,11 @@ import com.unciv.ui.utils.enable import com.unciv.ui.worldscreen.WorldScreen class IdleUnitButton internal constructor(internal val worldScreen: WorldScreen) : TextButton("Select next idle unit", CameraStageBaseScreen.skin) { + + fun getTilesWithIdleUnits() = worldScreen.civInfo.gameInfo.tileMap.values.filter { it.hasIdleUnit() && it.unit!!.owner == worldScreen.civInfo.civName } init { addClickListener { - val tilesWithIdleUnits = worldScreen.civInfo.gameInfo.tileMap.values.filter { it.hasIdleUnit() && it.unit!!.owner == worldScreen.civInfo.civName } + val tilesWithIdleUnits = getTilesWithIdleUnits() val tileToSelect: TileInfo if (!tilesWithIdleUnits.contains(worldScreen.tileMapHolder.selectedTile)) @@ -27,7 +29,7 @@ class IdleUnitButton internal constructor(internal val worldScreen: WorldScreen) } internal fun update() { - if (worldScreen.civInfo.gameInfo.tileMap.values.any { it.hasIdleUnit() }) enable() + if (getTilesWithIdleUnits().isNotEmpty()) enable() else disable() } }