summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-12-19 16:01:54 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-12-19 16:01:54 +0100
commit06462e18ec111a0662322ef221991dd0b547eded (patch)
treeb8e28200051bd3a0d4f4138dc81425ae8c315b40 /core
parent2d1e82949b9c359a4fab09d42c7b2f73380f3010 (diff)
downloadRustAndDust-06462e18ec111a0662322ef221991dd0b547eded.zip
RustAndDust-06462e18ec111a0662322ef221991dd0b547eded.tar.gz
StateSelect: select unit on click only if can do something
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index ed64a0e..7573132 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -114,12 +114,16 @@ public class StateSelect extends StateCommon
if (isEnemy && !ctrl.cfg.showEnemyPossibilities)
return;
- map.selectHex(selectedHex);
- // moves and targets == 0 if selectedUnit can't be activated for
- if (map.collectPossibleMoves(selectedUnit) > 0)
+ int moves = map.collectPossibleMoves(selectedUnit);
+ int targets = map.collectPossibleTargets(selectedUnit, (isEnemy ? ctrl.player.units : ctrl.opponent.units));
+
+ if (moves > 0)
map.collectMoveableUnits(selectedUnit);
- map.collectPossibleTargets(selectedUnit, (isEnemy ? ctrl.player.units : ctrl.opponent.units));
- showPossibilities(selectedUnit);
+
+ if ((moves > 0) || (targets > 0)) {
+ map.selectHex(selectedHex);
+ showPossibilities(selectedUnit);
+ }
ctrl.hud.actionButtons.show((ctrl.player.canPromote(selectedUnit)) ? Buttons.PROMOTE.b : 0 );
TankOnTank.debug(" select " + selectedHex + selectedUnit + (isEnemy ? " enemy " : " friend "));