diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-19 17:26:24 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-19 17:26:24 +0100 |
commit | 050015f59e3f30980d2e09ad2e0057867c068031 (patch) | |
tree | d3784ddc31c3461d91bdc7abad0f93aba887e2e0 /core/src/ch/asynk/tankontank/game | |
parent | 48eded8cfa88420fd21dd3effc5aafca5d6370b8 (diff) | |
download | RustAndDust-050015f59e3f30980d2e09ad2e0057867c068031.zip RustAndDust-050015f59e3f30980d2e09ad2e0057867c068031.tar.gz |
StateEscape: if exit from unit hex, build stay path, add runtime exitHex validation
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateEscape.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/ch/asynk/tankontank/game/states/StateEscape.java b/core/src/ch/asynk/tankontank/game/states/StateEscape.java index 98e4a8b..2d8eefd 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateEscape.java +++ b/core/src/ch/asynk/tankontank/game/states/StateEscape.java @@ -1,6 +1,7 @@ package ch.asynk.tankontank.game.states; import ch.asynk.tankontank.game.Zone; +import ch.asynk.tankontank.game.Hex; import ch.asynk.tankontank.game.Unit; public class StateEscape extends StateCommon @@ -48,12 +49,16 @@ public class StateEscape extends StateCommon // ctrl.hud.notify("Escape " + unit); Zone exitZone = ctrl.battle.getExitZone(unit); + Hex hex = unit.getHex(); - if (map.possiblePaths.size() == 1) - map.possiblePaths.setExit(exitZone.orientation); - else - map.possiblePaths.build(map.getAdjTileAt(unit.getTile(), exitZone.orientation)); - map.possiblePaths.orientation = exitZone.orientation; + if (selectedHex == hex) + map.possiblePaths.build(hex); + + Hex exitHex = (Hex) map.possiblePaths.to; + if (!exitZone.contains(exitHex)) + throw new RuntimeException(String.format("%s not in exitZone", exitHex)); + + map.possiblePaths.setExit(exitZone.orientation); unit.hideMoveable(); map.hidePath(to); |