summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-05-23 16:11:03 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-05-23 16:11:03 +0200
commitbfb98786729afd0fd043d42e18dfd0eb5d5807a3 (patch)
tree5fc6f4c90fcb3a295a0e03f604b2a1501432b1a9 /core/src/ch/asynk
parentd13316935979828d80094ccb4342bda1ac67e637 (diff)
downloadRustAndDust-bfb98786729afd0fd043d42e18dfd0eb5d5807a3.zip
RustAndDust-bfb98786729afd0fd043d42e18dfd0eb5d5807a3.tar.gz
add PlayerRecord
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/util/PlayerRecord.java85
1 files changed, 85 insertions, 0 deletions
diff --git a/core/src/ch/asynk/rustanddust/util/PlayerRecord.java b/core/src/ch/asynk/rustanddust/util/PlayerRecord.java
new file mode 100644
index 0000000..efd12de
--- /dev/null
+++ b/core/src/ch/asynk/rustanddust/util/PlayerRecord.java
@@ -0,0 +1,85 @@
+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 PlayerRecord implements List.ListElement, Disposable, Pool.Poolable
+{
+ public int id;
+ public String name;
+ public String email;
+ public String hash;
+ public String s;
+
+ public static Collection<List.ListElement> list = new IterableArray<List.ListElement>(10);
+
+ private static final Pool<PlayerRecord> gameRecordPool = new Pool<PlayerRecord>()
+ {
+ @Override
+ protected PlayerRecord newObject() {
+ return new PlayerRecord();
+ }
+ };
+
+ public static void clearPool()
+ {
+ gameRecordPool.clear();
+ }
+
+ public static PlayerRecord get()
+ {
+ PlayerRecord r = gameRecordPool.obtain();
+ return r;
+ }
+
+ public static PlayerRecord get(int idx)
+ {
+ return (PlayerRecord) list.get(idx);
+ }
+
+ public static PlayerRecord remove(int idx)
+ {
+ return (PlayerRecord) list.remove(idx);
+ }
+
+ public static void clearList()
+ {
+ for(List.ListElement r : list)
+ ((PlayerRecord) r).dispose();
+ list.clear();
+ }
+
+ public PlayerRecord()
+ {
+ }
+
+ @Override
+ public void reset()
+ {
+ this.s = null;
+ }
+
+ @Override
+ public void dispose()
+ {
+ gameRecordPool.free(this);
+ }
+
+ @Override
+ public String s()
+ {
+ if (s == null) {
+ s = String.format("%s - %s", name , (hasEmail() ? "OK" : "-"));
+ }
+ return s;
+ }
+
+ public boolean hasEmail()
+ {
+ return (this.email != null && !this.email.isEmpty());
+ }
+}