summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Struct')
-rw-r--r--src/Struct/Flags.elm40
-rw-r--r--src/Struct/Model.elm3
-rw-r--r--src/Struct/Player.elm21
-rw-r--r--src/Struct/ServerReply.elm3
4 files changed, 63 insertions, 4 deletions
diff --git a/src/Struct/Flags.elm b/src/Struct/Flags.elm
new file mode 100644
index 0000000..0e2ca14
--- /dev/null
+++ b/src/Struct/Flags.elm
@@ -0,0 +1,40 @@
+module Struct.Flags exposing
+ (
+ Type,
+ maybe_get_param
+ )
+
+-- Elm -------------------------------------------------------------------------
+import List
+
+-- Shared ----------------------------------------------------------------------
+import Util.List
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ url_params : (List (List String))
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+maybe_get_param : String -> Type -> (Maybe String)
+maybe_get_param param flags =
+ case
+ (Util.List.get_first
+ (\e -> ((List.head e) == (Just param)))
+ flags.url_params
+ )
+ of
+ Nothing -> Nothing
+ (Just a) ->
+ case (List.tail a) of
+ Nothing -> Nothing
+ (Just b) -> (List.head b)
diff --git a/src/Struct/Model.elm b/src/Struct/Model.elm
index 8a4f75d..6d4a588 100644
--- a/src/Struct/Model.elm
+++ b/src/Struct/Model.elm
@@ -14,7 +14,6 @@ import Array
import Struct.Flags
import Struct.Error
import Struct.Player
-import Struct.UI
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -38,7 +37,7 @@ new flags =
{
flags = flags,
error = Nothing,
- players = (Array.new)
+ players = (Array.empty)
}
reset : Type -> Type
diff --git a/src/Struct/Player.elm b/src/Struct/Player.elm
index 7221fb9..6a81daf 100644
--- a/src/Struct/Player.elm
+++ b/src/Struct/Player.elm
@@ -2,8 +2,13 @@ module Struct.Player exposing
(
Type,
get_ix,
+ set_ix,
get_id,
+ set_id,
+ get_url_prefix,
+ set_url_prefix,
get_username,
+ set_username,
get_campaigns,
get_invasions,
get_events,
@@ -26,6 +31,7 @@ type alias Type =
ix : Int,
id : String,
name : String,
+ url_prefix : String,
campaigns : (List Struct.BattleSummary.Type),
invasions : (List Struct.BattleSummary.Type),
events : (List Struct.BattleSummary.Type)
@@ -41,12 +47,27 @@ type alias Type =
get_ix : Type -> Int
get_ix t = t.ix
+set_ix : Int -> Type -> Type
+set_ix val t = {t | ix = val}
+
get_id : Type -> String
get_id t = t.id
+set_id : String -> Type -> Type
+set_id str t = {t | id = str}
+
get_username : Type -> String
get_username t = t.name
+set_username : String -> Type -> Type
+set_username str t = {t | name = str}
+
+get_url_prefix : Type -> String
+get_url_prefix t = t.url_prefix
+
+set_url_prefix : String -> Type -> Type
+set_url_prefix str t = {t | url_prefix = str}
+
get_campaigns : Type -> (List Struct.BattleSummary.Type)
get_campaigns t = t.campaigns
diff --git a/src/Struct/ServerReply.elm b/src/Struct/ServerReply.elm
index fb4967b..65fc063 100644
--- a/src/Struct/ServerReply.elm
+++ b/src/Struct/ServerReply.elm
@@ -11,8 +11,7 @@ import Struct.Player
type Type =
Okay
- | Disconnected
- | SetPlayer Struct.Player.Type
+-- | SetBattles (List, List, List)
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------