diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/OrderList.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/OrderList.java b/core/src/ch/asynk/tankontank/engine/OrderList.java index 60b0545..17836da 100644 --- a/core/src/ch/asynk/tankontank/engine/OrderList.java +++ b/core/src/ch/asynk/tankontank/engine/OrderList.java @@ -3,7 +3,11 @@ package ch.asynk.tankontank.engine; import java.util.LinkedList; import java.util.Iterator; -public class OrderList extends LinkedList<Order> +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonValue; +import com.badlogic.gdx.utils.JsonWriter.OutputType; + +public class OrderList extends LinkedList<Order> implements Json.Serializable { public void dispose(Pawn pawn) { @@ -35,4 +39,26 @@ public class OrderList extends LinkedList<Order> o.dispose(); clear(); } + + public String toJson() + { + Json json = new Json(); + json.setOutputType(OutputType.json); + return json.toJson(this); + } + + @Override + public void write(Json json) + { + 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) + } } |