summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Struct/Model.elm')
-rw-r--r--src/Struct/Model.elm64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Struct/Model.elm b/src/Struct/Model.elm
new file mode 100644
index 0000000..747a39e
--- /dev/null
+++ b/src/Struct/Model.elm
@@ -0,0 +1,64 @@
+module Struct.Model exposing
+ (
+ Type,
+ new,
+ invalidate,
+ reset,
+ clear_error
+ )
+
+-- Elm -------------------------------------------------------------------------
+
+-- Shared ----------------------------------------------------------------------
+import Struct.Flags
+
+-- Main Menu -------------------------------------------------------------------
+import Struct.Error
+import Struct.Player
+import Struct.UI
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ flags: Struct.Flags.Type,
+ error: (Maybe Struct.Error.Type),
+ player_id: String,
+ session_token: String,
+ player: Struct.Player.Type,
+ ui: Struct.UI.Type
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Struct.Flags.Type -> Type
+new flags =
+ {
+ flags = flags,
+ error = Nothing,
+ player_id = flags.user_id,
+ session_token = flags.token,
+ player = (Struct.Player.none),
+ ui = (Struct.UI.default)
+ }
+
+reset : Type -> Type
+reset model =
+ {model |
+ error = Nothing
+ }
+
+invalidate : Struct.Error.Type -> Type -> Type
+invalidate err model =
+ {model |
+ error = (Just err)
+ }
+
+clear_error : Type -> Type
+clear_error model = {model | error = Nothing}