From 9ec5806bc721734923ff4c93f7ef1f97a6a03248 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Thu, 13 Sep 2018 16:51:08 +0200 Subject: Starting an browser extension for TO... --- src/Struct/BattleSummary.elm | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/Struct/BattleSummary.elm (limited to 'src/Struct/BattleSummary.elm') diff --git a/src/Struct/BattleSummary.elm b/src/Struct/BattleSummary.elm new file mode 100644 index 0000000..adab965 --- /dev/null +++ b/src/Struct/BattleSummary.elm @@ -0,0 +1,65 @@ +module Struct.BattleSummary exposing + ( + Type, + get_id, + get_name, + get_last_edit, + is_players_turn, + decoder, + none + ) + +-- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +-- Main Menu ------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + id : String, + name : String, + last_edit : String, + is_players_turn : Bool + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_id : Type -> String +get_id t = t.id + +get_name : Type -> String +get_name t = t.name + +get_last_edit : Type -> String +get_last_edit t = t.last_edit + +is_players_turn : Type -> Bool +is_players_turn t = t.is_players_turn + +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.Pipeline.decode + Type + |> (Json.Decode.Pipeline.required "id" Json.Decode.string) + |> (Json.Decode.Pipeline.required "nme" Json.Decode.string) + |> (Json.Decode.Pipeline.required "ldt" Json.Decode.string) + |> (Json.Decode.Pipeline.required "ipt" Json.Decode.bool) + ) + +none : Type +none = + { + id = "", + name = "Unknown", + last_edit = "Never", + is_players_turn = False + } -- cgit v1.2.3-70-g09d2