summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/game/battles
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-21 13:56:40 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-21 13:56:40 +0100
commita3ad4c8f21ef37bd0c0c6c5989f5b7d43b78a7fa (patch)
tree59ca1d79d838370d146d7543aa28bcce04a55e42 /core/src/ch/asynk/rustanddust/game/battles
parent677813e7fd80c3f9e3fd9b6db15046c1eea97b29 (diff)
downloadRustAndDust-a3ad4c8f21ef37bd0c0c6c5989f5b7d43b78a7fa.zip
RustAndDust-a3ad4c8f21ef37bd0c0c6c5989f5b7d43b78a7fa.tar.gz
Battle,Map5Marshal: implements util/Marshal
Diffstat (limited to 'core/src/ch/asynk/rustanddust/game/battles')
-rw-r--r--core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
index 9fe66f8..e0afc5f 100644
--- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
+++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java
@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonWriter.OutputType;
+import ch.asynk.rustanddust.util.Marshal;
import ch.asynk.rustanddust.game.Battle;
import ch.asynk.rustanddust.game.Player;
import ch.asynk.rustanddust.game.State;
@@ -105,26 +106,44 @@ public abstract class BattleCommon implements Battle
}
@Override
- public void load(int turn, String payload)
+ public void load(Marshal.Mode mode, int turn, String payload)
{
this.turnCount = turn;
JsonValue root = new JsonReader().parse(payload);
- map.load(root, players);
+ load(mode, root);
this.currentPlayer = players[0];
}
@Override
- public String unload(boolean full)
+ public void load(Marshal.Mode mode, JsonValue value)
+ {
+ if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE))
+ map.loadPlayers(value, players);
+ map.load(mode, value);
+ }
+
+ @Override
+ public String unload(Marshal.Mode mode)
{
Json json = new Json(OutputType.json);
writer.getBuffer().setLength(0);
json.setWriter(writer);
- map.unload(json, full, getPlayer(), getOpponent());
+ unload(mode, json);
writer.flush();
return writer.toString();
}
@Override
+ public void unload(Marshal.Mode mode, Json json)
+ {
+ json.writeObjectStart();
+ if((mode == Marshal.Mode.FULL) || (mode == Marshal.Mode.STATE))
+ map.unloadPlayers(json, getPlayer(), getOpponent());
+ map.unload(mode, json);
+ json.writeObjectEnd();
+ }
+
+ @Override
public boolean actionDone()
{
boolean burn = (map.unitsActivatedSize() > 0);