summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-03-14 16:31:56 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-03-14 16:31:56 +0100
commita7087199d26372ef67f568e9ca422982ca92d6fb (patch)
tree935dc3c3cf530a0e09463d8c374b2951cc325988 /core/src/ch/asynk
parent390ae12c9d9b6a14cec03d6cc74b8e3d2f18027f (diff)
downloadRustAndDust-a7087199d26372ef67f568e9ca422982ca92d6fb.zip
RustAndDust-a7087199d26372ef67f568e9ca422982ca92d6fb.tar.gz
add util/TurnRecord
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/util/TurnRecord.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/TurnRecord.java b/core/src/ch/asynk/rustanddust/util/TurnRecord.java
new file mode 100644
index 0000000..e7ed117
--- /dev/null
+++ b/core/src/ch/asynk/rustanddust/util/TurnRecord.java
@@ -0,0 +1,72 @@
+package ch.asynk.rustanddust.util;
+
+import com.badlogic.gdx.utils.Pool;
+import com.badlogic.gdx.utils.Disposable;
+
+import ch.asynk.rustanddust.ui.List;
+import ch.asynk.rustanddust.engine.util.Collection;
+import ch.asynk.rustanddust.engine.util.IterableArray;
+
+public class TurnRecord implements List.ListElement, Disposable, Pool.Poolable
+{
+ public int id;
+ public int game;
+ public int turn;
+ public int player;
+ public String hash;
+ public String payload;
+
+ public static Collection<List.ListElement> list = new IterableArray<List.ListElement>(10);
+
+ private static final Pool<TurnRecord> turnRecordPool = new Pool<TurnRecord>()
+ {
+ @Override
+ protected TurnRecord newObject() {
+ return new TurnRecord();
+ }
+ };
+
+ public static void clearPool()
+ {
+ turnRecordPool.clear();
+ }
+
+ public static TurnRecord get()
+ {
+ TurnRecord r = turnRecordPool.obtain();
+ return r;
+ }
+
+ public static TurnRecord get(int idx)
+ {
+ return (TurnRecord) list.get(idx);
+ }
+
+ public static void clearList()
+ {
+ for(List.ListElement r : list)
+ ((TurnRecord) r).dispose();
+ list.clear();
+ }
+
+ public TurnRecord()
+ {
+ }
+
+ @Override
+ public void reset()
+ {
+ }
+
+ @Override
+ public void dispose()
+ {
+ turnRecordPool.free(this);
+ }
+
+ @Override
+ public String s()
+ {
+ return String.format("turn(id): g:%d t:%d p:%d", id, game, turn, player);
+ }
+}