summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-17 18:20:50 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-17 18:20:50 +0100 |
commit | cc497e16bb17b71c85fa144da0408514e39751a9 (patch) | |
tree | 0770d03ef2b2320872107da90fca274b50254b95 | |
parent | 14a7576ecf56f385d78e0c9ba84b895679c42ee8 (diff) |
Adds missing files.
-rw-r--r-- | src/battle/src/Comm/AddPortrait.elm | 24 | ||||
-rw-r--r-- | src/battle/src/Struct/Portrait.elm | 68 |
2 files changed, 92 insertions, 0 deletions
diff --git a/src/battle/src/Comm/AddPortrait.elm b/src/battle/src/Comm/AddPortrait.elm new file mode 100644 index 0000000..1cceb5f --- /dev/null +++ b/src/battle/src/Comm/AddPortrait.elm @@ -0,0 +1,24 @@ +module Comm.AddPortrait exposing (decode) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode + +-- Battle ---------------------------------------------------------------------- +import Struct.Portrait +import Struct.ServerReply + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +internal_decoder : Struct.Portrait.Type -> Struct.ServerReply.Type +internal_decoder pt = (Struct.ServerReply.AddPortrait pt) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decode : (Json.Decode.Decoder Struct.ServerReply.Type) +decode = (Json.Decode.map (internal_decoder) (Struct.Portrait.decoder)) diff --git a/src/battle/src/Struct/Portrait.elm b/src/battle/src/Struct/Portrait.elm new file mode 100644 index 0000000..9d62d02 --- /dev/null +++ b/src/battle/src/Struct/Portrait.elm @@ -0,0 +1,68 @@ +module Struct.Portrait exposing + ( + Type, + Ref, + none, + get_id, + get_name, + get_body_id, + get_icon_id, + decoder + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Battle ---------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String, + body_id : String, + icon_id : String + } + +type alias Ref = String + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +none : Type +none = + { + id = "cat", + name = "Black Cat", + body_id = "mammal", + icon_id = "cat" + } + +get_id : Type -> String +get_id p = p.id + +get_name : Type -> String +get_name p = p.name + +get_body_id : Type -> String +get_body_id p = p.body_id + +get_icon_id : Type -> String +get_icon_id p = p.icon_id + +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.succeed + Type + |> (Json.Decode.Pipeline.required "id" Json.Decode.string) + |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) + |> (Json.Decode.Pipeline.required "bid" Json.Decode.string) + |> (Json.Decode.Pipeline.required "iid" Json.Decode.string) + ) |