diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-10 12:58:30 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-05-10 12:58:30 +0200 |
commit | 699d99ec7c2fb68cdda77e994d8329f4e1f47df6 (patch) | |
tree | a7fa8bae82f195fc53efe47ef9b8e6ec10c07b9a | |
parent | b85d0270140b30a6575a2617575dfa1450d2ab61 (diff) | |
download | RustAndDust-699d99ec7c2fb68cdda77e994d8329f4e1f47df6.zip RustAndDust-699d99ec7c2fb68cdda77e994d8329f4e1f47df6.tar.gz |
Marshal: add Mode.PLAYER to load currentPlayer AP
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java | 6 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/util/Marshal.java | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index 20f6a25..255aa6c 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -102,7 +102,9 @@ public abstract class BattleCommon implements Battle public void load(Marshal.Mode mode, JsonValue value) { - if (mode == Marshal.Mode.PLAYERS) { + if (mode == Marshal.Mode.PLAYER) { + map.loadPlayerAP(value, 0, currentPlayer); + } else if (mode == Marshal.Mode.PLAYERS) { map.loadPlayers(value, players); this.currentPlayer = players[0]; } else { diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java index d1d7ccc..dc7554f 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java @@ -280,6 +280,12 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal Unit.blockId = false; } + public void loadPlayerAP(JsonValue v, int idx, Player player) + { + JsonValue a = v.get("players").get(idx).get("v"); + player.setTurn(a.getInt(0), a.getInt(1), a.getInt(2)); + } + private Player loadPlayer(JsonValue v) { Player p = new Player(Army.valueOf(v.getString("a"))); diff --git a/core/src/ch/asynk/rustanddust/util/Marshal.java b/core/src/ch/asynk/rustanddust/util/Marshal.java index f805fa1..f2e1b47 100644 --- a/core/src/ch/asynk/rustanddust/util/Marshal.java +++ b/core/src/ch/asynk/rustanddust/util/Marshal.java @@ -10,6 +10,7 @@ public interface Marshal PLAYERS, MAP, ORDERS, + PLAYER, } public void unload(Mode mode, Json json); |