summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-02 14:56:02 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-02 14:56:02 +0100
commit47ecdf87d8c1e1df831e0e616a554a912a65a6d6 (patch)
tree95818158fdb3c1976cf8875d91f16841cad8b3cd /core/src/ch
parent60e66ef079c648f142724aaab317c7bce89fb39e (diff)
downloadRustAndDust-47ecdf87d8c1e1df831e0e616a554a912a65a6d6.zip
RustAndDust-47ecdf87d8c1e1df831e0e616a554a912a65a6d6.tar.gz
Order[List]: remove Json stuff
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Order.java93
-rw-r--r--core/src/ch/asynk/rustanddust/game/OrderList.java32
2 files changed, 2 insertions, 123 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/Order.java b/core/src/ch/asynk/rustanddust/game/Order.java
index 552b647..09f17a3 100644
--- a/core/src/ch/asynk/rustanddust/game/Order.java
+++ b/core/src/ch/asynk/rustanddust/game/Order.java
@@ -2,14 +2,12 @@ package ch.asynk.rustanddust.game;
import com.badlogic.gdx.utils.Pool;
import com.badlogic.gdx.utils.Disposable;
-import com.badlogic.gdx.utils.Json;
-import com.badlogic.gdx.utils.JsonValue;
import ch.asynk.rustanddust.engine.Move;
import ch.asynk.rustanddust.engine.Tile;
import ch.asynk.rustanddust.engine.util.Collection;
-public class Order implements Disposable, Pool.Poolable, Json.Serializable, Comparable<Unit>
+public class Order implements Disposable, Pool.Poolable, Comparable<Unit>
{
public enum OrderType
{
@@ -119,93 +117,4 @@ public class Order implements Disposable, Pool.Poolable, Json.Serializable, Comp
this.unitType = unit.type;
this.unitHex = unit.getHex();
}
-
- @Override
- public void write(Json json)
- {
- json.writeValue("type", type);
- json.writeObjectStart("unit");
- json.writeValue("id", unitId);
- json.writeValue("type", unitType);
- json.writeValue("hq", unit.hq);
- json.writeValue("ace", unit.ace);
- writeHex(json, "tile", unitHex);
- json.writeObjectEnd();
- if (move != null) writeMove(json, "move", move);
- if (engagement != null) writeEngagement(json, "engagement", engagement);
- }
-
- private void writeMove(Json json, String key, Move m)
- {
- json.writeObjectStart(key);
- json.writeValue("type", move.type);
- writeHex(json, "from", (Hex) move.from);
- writeHex(json, "to", (Hex) move.to);
- json.writeValue("orientation", move.orientation.r());
- writeTiles(json, "path", move.tiles);
- json.writeObjectEnd();
- }
-
- private void writeEngagement(Json json, String key, Engagement e)
- {
- json.writeObjectStart(key);
- writeUnit(json, "attacker", e.attacker);
- writeUnit(json, "defender", e.defender);
- writeUnits(json, "assists", e.assists);
- json.writeObjectStart("dice");
- json.writeValue("d1", e.d1);
- json.writeValue("d2", e.d2);
- json.writeValue("d3", e.d3);
- json.writeValue("d4", e.d4);
- json.writeObjectEnd();
- json.writeObjectStart("results");
- json.writeValue("success", e.success);
- json.writeValue("attackSum", e.attackSum);
- json.writeValue("defenseSum", e.defenseSum);
- json.writeObjectEnd();
- json.writeObjectEnd();
- }
-
- private void writeUnit(Json json, String key, Unit u)
- {
- if (key != null) json.writeObjectStart(key);
- else json.writeObjectStart();
- json.writeValue("id", u.id);
- json.writeValue("ace", u.ace);
- json.writeValue("army", u.getArmy());
- writeHex(json, "tile", u.getHex());
- json.writeObjectEnd();
- }
-
- private void writeUnits(Json json, String key, Collection<Unit> units)
- {
- json.writeArrayStart(key);
- for (Unit u : units)
- writeUnit(json, null, u);
- json.writeArrayEnd();
- }
-
- private void writeHex(Json json, String key, Hex t)
- {
- if (t == null) return;
- if (key != null) json.writeObjectStart(key);
- else json.writeObjectStart();
- json.writeValue("col", t.getCol());
- json.writeValue("row", t.getRow());
- json.writeObjectEnd();
- }
-
- private void writeTiles(Json json, String key, Collection<Tile> tiles)
- {
- json.writeArrayStart(key);
- for (Tile t : tiles)
- writeHex(json, null, (Hex) t);
- json.writeArrayEnd();
- }
-
- @Override
- public void read(Json json, JsonValue jsonMap)
- {
- // FIXME Order.read(Json, JsonValue);
- }
}
diff --git a/core/src/ch/asynk/rustanddust/game/OrderList.java b/core/src/ch/asynk/rustanddust/game/OrderList.java
index 5e7c295..820288c 100644
--- a/core/src/ch/asynk/rustanddust/game/OrderList.java
+++ b/core/src/ch/asynk/rustanddust/game/OrderList.java
@@ -3,12 +3,10 @@ package ch.asynk.rustanddust.game;
import java.util.Iterator;
import com.badlogic.gdx.utils.Json;
-import com.badlogic.gdx.utils.JsonValue;
-import com.badlogic.gdx.utils.JsonWriter.OutputType;
import ch.asynk.rustanddust.engine.util.IterableArray;
-public class OrderList extends IterableArray<Order> implements Json.Serializable
+public class OrderList extends IterableArray<Order>
{
private Player player;
@@ -56,32 +54,4 @@ public class OrderList extends IterableArray<Order> implements Json.Serializable
o.dispose();
clear();
}
-
- public String toJson(final Player player)
- {
- this.player = player;
- Json json = new Json();
- json.setOutputType(OutputType.json);
- return json.toJson(this);
- }
-
- @Override
- public void write(Json json)
- {
- json.writeObjectStart("player");
- json.writeValue("army", player.getName());
- json.writeValue("turn", player.getTurn());
- json.writeValue("aps", player.getAp());
- json.writeObjectEnd();
- json.writeArrayStart("commands");
- for (Order o : this)
- json.writeValue(o);
- json.writeArrayEnd();
- }
-
- @Override
- public void read(Json json, JsonValue jsonMap)
- {
- // TODO read(Json json, JsonValue jsonMap)
- }
}