From bd31cb16b530d0f65ee982cbe472aaae807c5979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 20 Feb 2015 15:30:57 +0100 Subject: OrderList: implements Json.Serializable, add String toJson() --- core/src/ch/asynk/tankontank/engine/OrderList.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.JsonValue; +import com.badlogic.gdx.utils.JsonWriter.OutputType; + +public class OrderList extends LinkedList implements Json.Serializable { public void dispose(Pawn pawn) { @@ -35,4 +39,26 @@ public class OrderList extends LinkedList 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) + } } -- cgit v1.1-2-g2b99