summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-03-15 18:16:55 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-03-15 18:16:55 +0100 |
commit | 6678cfe464ed9ee595f4f3dd7398dec1416454c9 (patch) | |
tree | 2700668874e13a81ec7467dcf26a1d246caa23ff /src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm | |
parent | 24efb898f526e0aa02a0e15b74436da8ba166cac (diff) |
[Broken] Starting a code refactoring...
Diffstat (limited to 'src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm')
-rw-r--r-- | src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm new file mode 100644 index 0000000..35f5260 --- /dev/null +++ b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm @@ -0,0 +1,66 @@ +module BattleCharacters.Struct.Portrait exposing + ( + Type, + Ref, + default, + get_id, + get_name, + get_body_id, + get_icon_id, + decoder + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String, + body_id : String, + icon_id : String + } + +type alias Ref = String + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +default : Type +default = + { + 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) + ) |