diff options
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Battle.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java | 14 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/ctrl/Solo.java | 4 |
3 files changed, 13 insertions, 7 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Battle.java b/core/src/ch/asynk/rustanddust/game/Battle.java index a545573..eb5b086 100644 --- a/core/src/ch/asynk/rustanddust/game/Battle.java +++ b/core/src/ch/asynk/rustanddust/game/Battle.java @@ -42,5 +42,5 @@ public interface Battle extends Marshal public String unload(Marshal.Mode mode); - public void load(Marshal.Mode mode, int turn, String payload); + public void load(Marshal.Mode mode, String payload); } diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index e0afc5f..968c657 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -106,9 +106,8 @@ public abstract class BattleCommon implements Battle } @Override - public void load(Marshal.Mode mode, int turn, String payload) + public void load(Marshal.Mode mode, String payload) { - this.turnCount = turn; JsonValue root = new JsonReader().parse(payload); load(mode, root); this.currentPlayer = players[0]; @@ -117,8 +116,11 @@ public abstract class BattleCommon implements Battle @Override public void load(Marshal.Mode mode, JsonValue value) { - if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE)) + if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE)) { + JsonValue v = value.get("battle"); + this.turnCount = v.getInt("turnCount"); map.loadPlayers(value, players); + } map.load(mode, value); } @@ -137,8 +139,12 @@ public abstract class BattleCommon implements Battle public void unload(Marshal.Mode mode, Json json) { json.writeObjectStart(); - if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE)) + if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE)) { + json.writeObjectStart("battle"); + json.writeValue("turnCount", turnCount); + json.writeObjectEnd(); map.unloadPlayers(json, getPlayer(), getOpponent()); + } map.unload(mode, json); json.writeObjectEnd(); } diff --git a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java index d7cda5c..5473cd5 100644 --- a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java +++ b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java @@ -28,8 +28,8 @@ public class Solo extends Ctrl } else { GameRecord r = game.db.loadGame(gameId); if (r != null) { - battle.load(Marshal.Mode.STATE, r.turn, r.state); - battle.load(Marshal.Mode.ORDERS, r.turn, r.orders); + battle.load(Marshal.Mode.STATE, r.state); + battle.load(Marshal.Mode.ORDERS, r.orders); battle.getMap().clearMarshalUnits(); r.dispose(); } else |