From f43bdee9d438e4b4dc85fe5c5a767bfd0c885849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 31 Mar 2016 11:44:57 +0200 Subject: Map5Marshal: handle Move.MoveType --- .../ch/asynk/rustanddust/game/map/Map5Marshal.java | 24 ++++++++++++++++++---- 1 file 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; } -- cgit v1.1-2-g2b99