summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:54:50 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 23:54:50 +0100
commit774a132366d7009b9cc2fbe98838586cf488d308 (patch)
tree948a324e790ae7a6c19eb6bc090eb7b497363c80 /core/src/ch/asynk/rustanddust
parent3fbaacf8ab9e77e8b964874226cbe1a2bf01bae8 (diff)
downloadRustAndDust-774a132366d7009b9cc2fbe98838586cf488d308.zip
RustAndDust-774a132366d7009b9cc2fbe98838586cf488d308.tar.gz
StateMove: fix checkExit(Hex) usage, and path building
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java35
1 files changed, 20 insertions, 15 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
index f7597ff..3a2bc76 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
@@ -16,8 +16,7 @@ public class StateMove extends StateCommon
);
if (prevState == StateType.WITHDRAW) {
- if (map.pathsSize() == 1)
- ctrl.setState(StateType.ROTATE);
+ completePath(map.pathsSize());
return;
}
@@ -110,14 +109,9 @@ public class StateMove extends StateCommon
if(unit != activeUnit)
changeUnit(unit);
} else if ((s == 0) && map.movesContains(hex)) {
- s = collectPaths(hex);
+ collectPaths(hex);
} else if (map.pathsContains(hex)) {
- s = togglePoint(hex, s);
- }
-
- if (s == 1) {
- if (!checkExit(activeUnit, hex))
- ctrl.setState(StateType.ROTATE);
+ togglePoint(hex, s);
}
}
@@ -133,6 +127,7 @@ public class StateMove extends StateCommon
if (activeUnit.canMove())
activeUnit.showActiveable();
}
+ to = null;
activeUnit = unit;
activeUnit.hideActiveable();
Hex hex = activeUnit.getHex();
@@ -145,19 +140,26 @@ public class StateMove extends StateCommon
checkExit(activeUnit);
}
- private int collectPaths(Hex hex)
+ private void collectPaths(Hex hex)
{
to = hex;
+ map.movesHide();
+ map.hexMoveShow(to);
int s = map.pathsBuild(to);
+ if (!checkExit(activeUnit, hex))
+ completePath(s);
+ }
+
+ private void completePath(int s)
+ {
if (cfg.autoPath && (s > 1))
s = map.pathsChooseBest();
- map.hexMoveShow(to);
- map.movesHide();
map.pathsShow();
- return s;
+ if (s == 1)
+ ctrl.setState(StateType.ROTATE);
}
- private int togglePoint(Hex hex, int s)
+ private void togglePoint(Hex hex, int s)
{
if (hex == activeUnit.getHex()) {
//
@@ -169,7 +171,10 @@ public class StateMove extends StateCommon
map.pathsShow();
}
- return s;
+ if (s == 1) {
+ if (!checkExit(activeUnit, hex))
+ ctrl.setState(StateType.ROTATE);
+ }
}
private boolean checkExit(Unit unit)