summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-07 23:41:23 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-07 23:41:23 +0100
commit7cdf36afd32432511484c14fb8798db0cfc27340 (patch)
tree4b9ea0b77825dd835462623fe0194654f2a789fc
parent6bfdd9ced7d32dcc6ef4f4add53ad1e003a120bc (diff)
downloadRustAndDust-7cdf36afd32432511484c14fb8798db0cfc27340.zip
RustAndDust-7cdf36afd32432511484c14fb8798db0cfc27340.tar.gz
Map: paths is now protected
-rw-r--r--core/src/ch/asynk/rustanddust/game/Map.java26
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateBreak.java6
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateMove.java20
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateRotate.java14
-rw-r--r--core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java8
5 files changed, 49 insertions, 25 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Map.java b/core/src/ch/asynk/rustanddust/game/Map.java
index 8c7c9ba..9eb3e65 100644
--- a/core/src/ch/asynk/rustanddust/game/Map.java
+++ b/core/src/ch/asynk/rustanddust/game/Map.java
@@ -38,7 +38,7 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
private final Ctrl ctrl;
protected final HexSet moves;
- public final PathBuilder paths;
+ protected final PathBuilder paths;
protected final UnitList moveableUnits;
protected final UnitList targetUnits;
@@ -178,6 +178,30 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
return 0;
}
+ public void pathsClear() { paths.clear(); }
+
+ public int pathsSize() { return paths.size(); }
+
+ public void pathsInit(Unit unit) { paths.init(unit); }
+
+ public void pathsInit(Unit unit, Hex hex) { paths.init(unit, hex); }
+
+ public boolean pathsIsSet() { return paths.isSet(); }
+
+ public boolean pathsCanExit(Orientation o) { return paths.canExit(o); }
+
+ public void pathsSetExit(Orientation o) { paths.setExit(o); }
+
+ public int pathsBuild(Hex hex) { return pathsBuild(hex); }
+
+ public boolean pathsContains(Hex hex) { return paths.contains(hex); }
+
+ public void pathsSetOrientation(Orientation o) { paths.orientation = o; }
+
+ public Hex pathsTo() { return (Hex) paths.to; }
+
+ public int pathsChooseOne() { return paths.choosePath(); }
+
public int pathsToggleHex(Hex hex)
{
boolean enable = !hex.isOverlayEnabled(Hex.MOVE);
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
index 3768e6f..1555f6b 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateBreak.java
@@ -78,9 +78,9 @@ public class StateBreak extends StateCommon
{
if (activeUnit == null) return;
- map.paths.init(activeUnit);
- if (map.paths.build(to) == 1) {
- map.paths.orientation = o;
+ map.pathsInit(activeUnit);
+ if (map.pathsBuild(to) == 1) {
+ map.pathsSetOrientation(o);
map.moveUnit(activeUnit);
ctrl.setAfterAnimationState(StateType.DONE);
} else
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateMove.java b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
index 6410c67..5df3048 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateMove.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateMove.java
@@ -16,18 +16,18 @@ public class StateMove extends StateCommon
| (ctrl.cfg.canCancel ? Buttons.ABORT.b : 0));
if (prevState == StateType.WITHDRAW) {
- if (map.paths.size() == 1)
+ if (map.pathsSize() == 1)
ctrl.setState(StateType.ROTATE);
return;
}
- map.paths.clear();
+ map.pathsClear();
if (prevState == StateType.SELECT) {
// use selectedHex and selectedUnit
activeUnit = selectedUnit;
activeUnit.showMoveable();
- map.paths.init(activeUnit);
+ map.pathsInit(activeUnit);
map.collectAndShowMovesAndAssits(activeUnit);
if (to != null) {
// quick move -> replay touchUp
@@ -104,12 +104,12 @@ public class StateMove extends StateCommon
if (to != null)
map.pathHide(to);
to = null;
- map.paths.clear();
+ map.pathsClear();
ctrl.setState(StateType.ROTATE);
return;
}
- int s = map.paths.size();
+ int s = map.pathsSize();
Unit unit = upHex.getUnit();
@@ -118,7 +118,7 @@ public class StateMove extends StateCommon
changeUnit(unit);
} else if ((s == 0) && map.movesContains(upHex)) {
s = collectPaths(upHex);
- } else if (map.paths.contains(upHex)) {
+ } else if (map.pathsContains(upHex)) {
s = togglePoint(downHex, s);
}
@@ -142,7 +142,7 @@ public class StateMove extends StateCommon
}
activeUnit = unit;
Hex hex = activeUnit.getHex();
- map.paths.init(activeUnit, hex);
+ map.pathsInit(activeUnit, hex);
activeUnit.showMoveable();
map.movesHide();
map.movesCollect(activeUnit);
@@ -156,9 +156,9 @@ public class StateMove extends StateCommon
private int collectPaths(Hex hex)
{
to = hex;
- int s = map.paths.build(to);
+ int s = map.pathsBuild(to);
if (s > 1)
- s = map.paths.choosePath();
+ s = map.pathsChooseOne();
map.hexMoveShow(to);
map.movesHide();
map.pathsShow();
@@ -187,7 +187,7 @@ public class StateMove extends StateCommon
Zone exitZone = ctrl.battle.getExitZone(unit);
if ((exitZone == null) || !exitZone.contains(hex))
return false;
- if ((unit.getHex() != hex) && !map.paths.canExit(exitZone.orientation))
+ if ((unit.getHex() != hex) && !map.pathsCanExit(exitZone.orientation))
return false;
ctrl.setState(StateType.WITHDRAW);
return true;
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
index a7dffa0..5c55a9d 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateRotate.java
@@ -21,13 +21,13 @@ public class StateRotate extends StateCommon
if (to == null)
to = activeUnit.getHex();
- if (!map.paths.isSet()) {
- map.paths.init(activeUnit);
- map.paths.build(to);
+ if (!map.pathsIsSet()) {
+ map.pathsInit(activeUnit);
+ map.pathsBuild(to);
}
- if (map.paths.size() != 1)
- RustAndDust.debug("ERROR: paths.size() == " + map.paths.size());
+ if (map.pathsSize() != 1)
+ RustAndDust.debug("ERROR: pathsSize() == " + map.pathsSize());
rotateOnly = (to == activeUnit.getHex());
@@ -45,7 +45,7 @@ public class StateRotate extends StateCommon
map.hexUnselect(activeUnit.getHex());
map.pathHide(to);
map.hexDirectionsHide(to);
- map.paths.clear();
+ map.pathsClear();
to = null;
}
@@ -96,7 +96,7 @@ public class StateRotate extends StateCommon
if (!activeUnit.justEntered() && rotateOnly && (o == activeUnit.getOrientation()))
return;
- map.paths.orientation = o;
+ map.pathsSetOrientation(o);
rotationSet = true;
if (ctrl.cfg.mustValidate) {
diff --git a/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java b/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
index 4e48d77..ed4251e 100644
--- a/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
+++ b/core/src/ch/asynk/rustanddust/game/states/StateWithdraw.java
@@ -49,14 +49,14 @@ public class StateWithdraw extends StateCommon
Hex hex = unit.getHex();
// rotation
- if (map.paths.to == null)
- map.paths.build(hex);
+ if (map.pathsTo() == null)
+ map.pathsBuild(hex);
- Hex exitHex = (Hex) map.paths.to;
+ Hex exitHex = (Hex) map.pathsTo();
if (!exitZone.contains(exitHex))
throw new RuntimeException(String.format("%s not in exitZone", exitHex));
- map.paths.setExit(exitZone.orientation);
+ map.pathsSetExit(exitZone.orientation);
unit.hideMoveable();
if (to != null)