summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-01-19 17:26:24 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-01-19 17:26:24 +0100
commit050015f59e3f30980d2e09ad2e0057867c068031 (patch)
treed3784ddc31c3461d91bdc7abad0f93aba887e2e0 /core
parent48eded8cfa88420fd21dd3effc5aafca5d6370b8 (diff)
downloadRustAndDust-050015f59e3f30980d2e09ad2e0057867c068031.zip
RustAndDust-050015f59e3f30980d2e09ad2e0057867c068031.tar.gz
StateEscape: if exit from unit hex, build stay path, add runtime exitHex validation
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/PossiblePaths.java5
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateEscape.java15
2 files changed, 13 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
index 49a317f..b54835e 100644
--- a/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
+++ b/core/src/ch/asynk/tankontank/engine/PossiblePaths.java
@@ -235,12 +235,13 @@ public class PossiblePaths implements Disposable
return filteredPaths.get(i);
}
- public void setExit(Orientation exit)
+ public void setExit(Orientation o)
{
+ orientation = o;
Path path = getPath(0);
path.cost += 1;
path.tiles.add(to);
- to = board.getAdjTileAt(to, exit);
+ to = board.getAdjTileAt(to, o);
}
private void printToErr(String what, List<Path> paths)
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);