From 6678cfe464ed9ee595f4f3dd7398dec1416454c9 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 15 Mar 2019 18:16:55 +0100 Subject: [Broken] Starting a code refactoring... --- .../BattleCharacters/Struct/Armor.elm | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/shared/battle-characters/BattleCharacters/Struct/Armor.elm (limited to 'src/shared/battle-characters/BattleCharacters/Struct/Armor.elm') diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm b/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm new file mode 100644 index 0000000..5cb99d6 --- /dev/null +++ b/src/shared/battle-characters/BattleCharacters/Struct/Armor.elm @@ -0,0 +1,74 @@ +module BattleCharacters.Struct.Armor exposing + ( + Type, + Ref, + new, + get_id, + get_name, + get_image_id, + get_omnimods, + decoder, + default, + none + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Battle ---------------------------------------------------------------------- +import Battle.Struct.Omnimods + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String, + omnimods : Battle.Struct.Omnimods.Type + } + +type alias Ref = String + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +new : String -> String -> Battle.Struct.Omnimods.Type -> Type +new id name omnimods = + { + id = id, + name = name, + omnimods = omnimods + } + +get_id : Type -> Ref +get_id ar = ar.id + +get_name : Type -> String +get_name ar = ar.name + +get_image_id : Type -> String +get_image_id ar = ar.id + +get_omnimods : Type -> Battle.Struct.Omnimods.Type +get_omnimods ar = ar.omnimods + +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 "omni" Battle.Struct.Omnimods.decoder) + ) + +none : Type +none = (new "0" "None" (Battle.Struct.Omnimods.none)) + +default : Type +default = (none) -- cgit v1.2.3-70-g09d2