diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateCommon.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateCommon.java b/core/src/ch/asynk/tankontank/game/states/StateCommon.java index 33d5343..e702ce4 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateCommon.java +++ b/core/src/ch/asynk/tankontank/game/states/StateCommon.java @@ -1,5 +1,6 @@ package ch.asynk.tankontank.game.states; +import ch.asynk.tankontank.engine.Zone; import ch.asynk.tankontank.game.Map; import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Unit; @@ -76,4 +77,19 @@ public abstract class StateCommon implements State map.hidePossibleTargets(); map.hideMoveablePawns(); } + + protected boolean checkExit(Unit unit, Hex hex) + { + Zone exitZone = ctrl.battle.getExitZone(unit); + if ((exitZone == null) || !exitZone.contains(hex)) + return false; + if (map.possiblePaths.size() == 1) { + // TODO pathCost called with applayToPawn from Board it updates Pawn.move + int left = (unit.getMovementPoints() - map.possiblePaths.pathCost(0)); + if (left < 1) + return false; + } + ctrl.setState(StateType.ESCAPE); + return true; + } } |