diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-18 23:22:01 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-01-18 23:22:01 +0100 |
commit | 0eb2eae843b58fe45883b96874dc876a074df250 (patch) | |
tree | 02504de5aa384283470972ac0478dfc81ecf44ad | |
parent | 05968c6347a66d62767d1bc49f1a7799b3b5cd00 (diff) | |
download | RustAndDust-0eb2eae843b58fe45883b96874dc876a074df250.zip RustAndDust-0eb2eae843b58fe45883b96874dc876a074df250.tar.gz |
Move: add static getEnter() and getSet()
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Move.java | 28 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 9 |
2 files changed, 18 insertions, 19 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Move.java b/core/src/ch/asynk/tankontank/engine/Move.java index b12b8da..0eb3c86 100644 --- a/core/src/ch/asynk/tankontank/engine/Move.java +++ b/core/src/ch/asynk/tankontank/engine/Move.java @@ -42,6 +42,22 @@ public class Move extends Path implements Iterable<Vector3> return m; } + public static Move getEnter(Pawn pawn, Tile to, Orientation orientation) + { + Move m = get(pawn, null, to, orientation, null); + m.type = MoveType.ENTER; + m.cost = to.costFrom(pawn, orientation); + return m; + } + + public static Move getSet(Pawn pawn, Tile to, Orientation orientation) + { + Move m = get(pawn, null, to, orientation, null); + m.type = MoveType.SET; + m.cost = 0; + return m; + } + public Pawn pawn; public Tile from; public Tile to; @@ -86,18 +102,6 @@ public class Move extends Path implements Iterable<Vector3> return (type != MoveType.ENTER); } - public void setSet() - { - type = MoveType.SET; - cost = 0; - } - - public void setEnter() - { - type = MoveType.ENTER; - cost = to.costFrom(pawn, orientation); - } - public void setExit() { type = MoveType.EXIT; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index eca6e64..7a28a70 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -273,10 +273,8 @@ public abstract class Map extends Board if (entry == Orientation.KEEP) return false; - Move move = Move.get(unit, null, to, entry, null); - move.setEnter(); - enterPawn(unit, move); + enterPawn(unit, Move.getEnter(unit, to, entry)); objectives.claim(to, unit.getArmy()); return true; } @@ -285,10 +283,7 @@ public abstract class Map extends Board { TankOnTank.debug("Map", String.format("set %s %s %s", to.toShort(), unit, entry)); - Move move = Move.get(unit, null, to, entry, null); - move.setSet(); - - setPawnOnto(unit, move); + setPawnOnto(unit, Move.getSet(unit, to, entry)); objectives.claim(to, unit.getArmy()); return true; } |