summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-20 15:30:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-20 15:30:57 +0100
commitbd31cb16b530d0f65ee982cbe472aaae807c5979 (patch)
tree07984a86582546f087ecdcacb1f57070f364e717 /core/src/ch/asynk
parent29044f762ade5424bdef22b8757bf50a8d3e4f85 (diff)
downloadRustAndDust-bd31cb16b530d0f65ee982cbe472aaae807c5979.zip
RustAndDust-bd31cb16b530d0f65ee982cbe472aaae807c5979.tar.gz
OrderList: implements Json.Serializable, add String toJson()
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/OrderList.java28
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)
+ }
}