summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-03-15 18:16:55 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-03-15 18:16:55 +0100
commit6678cfe464ed9ee595f4f3dd7398dec1416454c9 (patch)
tree2700668874e13a81ec7467dcf26a1d246caa23ff /src/shared/battle-map/BattleMap/Struct/Tile.elm
parent24efb898f526e0aa02a0e15b74436da8ba166cac (diff)
[Broken] Starting a code refactoring...
Diffstat (limited to 'src/shared/battle-map/BattleMap/Struct/Tile.elm')
-rw-r--r--src/shared/battle-map/BattleMap/Struct/Tile.elm77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/shared/battle-map/BattleMap/Struct/Tile.elm b/src/shared/battle-map/BattleMap/Struct/Tile.elm
new file mode 100644
index 0000000..9145b44
--- /dev/null
+++ b/src/shared/battle-map/BattleMap/Struct/Tile.elm
@@ -0,0 +1,77 @@
+module BattleMap.Struct.Tile exposing
+ (
+ Ref,
+ VariantID,
+ FamilyID,
+ Type,
+ get_id,
+ get_name,
+ get_cost,
+ get_omnimods,
+ get_family,
+ decoder
+ )
+
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+import Json.Decode
+import Json.Decode.Pipeline
+
+-- Battle ----------------------------------------------------------------------
+import Battle.Struct.Omnimods
+
+-- Local Module ----------------------------------------------------------------
+import Constants.UI
+import Constants.Movement
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Ref = String
+type alias VariantID = String
+type alias FamilyID = String
+
+type alias Type =
+ {
+ id : Ref,
+ name : String,
+ crossing_cost : Int,
+ family : FamilyID,
+ depth : Int,
+ omnimods : Battle.Struct.Omnimods.Type
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+get_id : Type -> Ref
+get_id tile = tile.id
+
+get_cost : Type -> Int
+get_cost tile = tile.crossing_cost
+
+get_name : Type -> String
+get_name tile = tile.name
+
+get_family : Type -> FamilyID
+get_family tile = tile.family
+
+get_omnimods : Type -> Battle.Struct.Omnimods.Type
+get_omnimods t = t.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 "ct" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "fa" Json.Decode.string)
+ |> (Json.Decode.Pipeline.required "de" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "omni" Battle.Struct.Omnimods.decoder)
+ )