summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-28 23:33:22 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-28 23:33:22 +0100
commit27ae3693d680528522ee87d2b7905153cf6754a6 (patch)
tree03358c279183d931dbd9c92d63365eea11c4172d /core/src/ch
parent3adfb61709282b45f09d852ab74010da67b348ed (diff)
downloadRustAndDust-27ae3693d680528522ee87d2b7905153cf6754a6.zip
RustAndDust-27ae3693d680528522ee87d2b7905153cf6754a6.tar.gz
Map: fix buildPossibleMoves(Pawn) and buildPossibleTargets(Pawn, Iterator<Pawn>) return values
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java8
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateSelect.java8
2 files changed, 13 insertions, 3 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 21f78ec..27e70bc 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -145,11 +145,19 @@ public abstract class Map extends Board
public int buildPossibleMoves(Pawn pawn)
{
+ if (!pawn.canMove()) {
+ possibleMoves.clear();
+ return 0;
+ }
return buildPossibleMoves(pawn, possibleMoves);
}
public int buildPossibleTargets(Pawn pawn, Iterator<Pawn> foes)
{
+ if (!pawn.canAttack()) {
+ possibleTargets.clear();
+ return 0;
+ }
// return buildPossibleTargets(pawn, possibleTargets);
return buildPossibleTargets(pawn, possibleTargets);
}
diff --git a/core/src/ch/asynk/tankontank/game/states/StateSelect.java b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
index 500f90d..ddddf6f 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateSelect.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateSelect.java
@@ -52,19 +52,21 @@ public class StateSelect extends StateCommon
hidePossibleTargetsMovesAssists();
if (hasUnit() && (!isEnemy || ctrl.cfg.showEnemyPossibilities)) {
+ // moves and targets == 0 if selectedUnit can't be activated for
int moves = map.buildPossibleMoves(selectedUnit);
int targets = 0;
if (isEnemy)
targets = map.buildPossibleTargets(selectedUnit, ctrl.player.unitIterator());
else
targets = map.buildPossibleTargets(selectedUnit, ctrl.opponent.unitIterator());
- int assists = map.buildMoveAssists(selectedUnit);
+ if (moves > 0)
+ map.collectMoveablePawns(selectedUnit);
showPossibleTargetsMovesAssists(selectedUnit);
ctrl.hud.show(
ctrl.player.canPromote(selectedUnit),
selectedUnit.canMove(),
- (selectedUnit.canMove() && (moves > 0)),
- (selectedUnit.canAttack() && (targets > 0)),
+ (moves > 0),
+ (targets > 0),
false,
false
);