summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-03-12 13:00:59 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-03-12 13:00:59 +0100
commit11a7a03a0088b2c4b8edc394469396d54190dc53 (patch)
tree7856475136a11a60bcf4c2980adfb5624a116b33 /src/struct/player.erl
parent98203d4d0034dab5db72737bcfb92017a11f3245 (diff)
Starting to work on the timeline feature.
Diffstat (limited to 'src/struct/player.erl')
-rw-r--r--src/struct/player.erl72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/struct/player.erl b/src/struct/player.erl
new file mode 100644
index 0000000..824e474
--- /dev/null
+++ b/src/struct/player.erl
@@ -0,0 +1,72 @@
+-module(player).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: string().
+
+-record
+(
+ player,
+ {
+ id :: id(),
+ timeline :: list(any())
+ }
+).
+
+-opaque struct() :: #player{}.
+
+-export_type([struct/0, id/0]).
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-export
+(
+ [
+ get_id/1,
+ get_timeline/1,
+ add_to_timeline/2,
+ reset_timeline/1
+ ]
+).
+
+-export
+(
+ [
+ new/1
+ ]
+).
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec get_id (struct()) -> id().
+get_id (Player) -> Player#player.id.
+
+-spec get_timeline (struct()) -> list(any()).
+get_timeline (Player) -> Player#player.timeline.
+
+-spec add_to_timeline (list(any()), struct()) -> struct().
+add_to_timeline (NewEvents, Player) ->
+ OldTimeline = Player#player.timeline,
+
+ Player#player
+ {
+ timeline = (OldTimeline ++ NewEvents)
+ }.
+
+-spec reset_timeline (struct()) -> struct().
+reset_timeline (Player) -> Player#player{ timeline = [] }.
+
+-spec new (id()) -> struct().
+new (ID) ->
+ #player
+ {
+ id = ID,
+ timeline = []
+ }.
+