diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-31 11:44:57 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-03-31 11:44:57 +0200 |
commit | f43bdee9d438e4b4dc85fe5c5a767bfd0c885849 (patch) | |
tree | bd081a53572743417f10ea20e68d5194039559fe /core/src/ch/asynk/rustanddust/game | |
parent | e66abf40b77d601b78b15ca775bbfbdbc45a4bf3 (diff) | |
download | RustAndDust-f43bdee9d438e4b4dc85fe5c5a767bfd0c885849.zip RustAndDust-f43bdee9d438e4b4dc85fe5c5a767bfd0c885849.tar.gz |
Map5Marshal: handle Move.MoveType
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java index 96e6290..38151b8 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java @@ -184,7 +184,7 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal private void unloadMoveOrder(Json json, Move m) { - json.writeValue("type", m.type); + json.writeValue("mType", m.type); json.writeValue("id", ((Unit) m.pawn).id); if (m.from != null) { json.writeArrayStart("from"); @@ -392,10 +392,10 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal private Order loadMoveOrder(JsonValue v) { Unit unit = findById(v.getInt("id")); + if (unit == null) return null; Hex from = loadHex(v, "from"); Hex to = loadHex(v, "to"); Orientation orientation = Orientation.fromRotation(v.get("to").getInt(2)); - if (unit == null) return null; Path path = null; JsonValue p = v.get("path"); @@ -407,9 +407,25 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal } } - Move move = Move.get(unit, from, to, orientation, path); + Move m = null; + switch(Move.MoveType.valueOf(v.getString("mType"))) { + case REGULAR: + m = Move.get(unit, from, to, orientation, path); + break; + case ENTER: + m = Move.getEnter(unit, to, orientation); + break; + case SET: + m = Move.getSet(unit, to, orientation); + break; + case EXIT: + m = Move.get(unit, from, to, orientation, path); + m.type = Move.MoveType.EXIT; + break; + } + Order o = Order.get(); - o.setMove(unit, move); + o.setMove(unit, m); return o; } |