summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battle/src/Struct/Tile.elm')
-rw-r--r-- | src/battle/src/Struct/Tile.elm | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/src/battle/src/Struct/Tile.elm b/src/battle/src/Struct/Tile.elm index c7c0d52..b41b233 100644 --- a/src/battle/src/Struct/Tile.elm +++ b/src/battle/src/Struct/Tile.elm @@ -1,6 +1,7 @@ module Struct.Tile exposing ( Ref, + VariantID, Type, Instance, Border, @@ -12,12 +13,12 @@ module Struct.Tile exposing get_name, get_borders, get_border_type_id, - get_border_variant_ix, + get_border_variant_id, get_cost, get_instance_cost, get_location, get_type_id, - get_variant_ix, + get_variant_id, get_local_variant_ix, get_omnimods, solve_tile_instance, @@ -40,11 +41,12 @@ import Struct.Omnimods -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- -------------------------------------------------------------------------------- -type alias Ref = Int +type alias Ref = String +type alias VariantID = String type alias Type = { - id : Int, + id : Ref, name : String, crossing_cost : Int, omnimods : Struct.Omnimods.Type @@ -52,16 +54,16 @@ type alias Type = type alias Border = { - type_id : Int, - variant_ix : Int + type_id : Ref, + variant_id : VariantID } type alias Instance = { location : Struct.Location.Type, crossing_cost : Int, - type_id : Int, - variant_ix : Int, + type_id : Ref , + variant_id : VariantID, borders : (List Border) } @@ -75,7 +77,7 @@ noise_function a b c = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -new : Int -> String -> Int -> Struct.Omnimods.Type -> Type +new : Ref -> String -> Int -> Struct.Omnimods.Type -> Type new id name crossing_cost omnimods = { id = id, @@ -84,26 +86,26 @@ new id name crossing_cost omnimods = omnimods = omnimods } -new_border : Int -> Int -> Border +new_border : Ref -> VariantID -> Border new_border a b = { type_id = a, - variant_ix = b + variant_id = b } new_instance : ( Struct.Location.Type -> - Int -> - Int -> + Ref -> + VariantID -> Int -> (List Border) -> Instance ) -new_instance location type_id variant_ix crossing_cost borders = +new_instance location type_id variant_id crossing_cost borders = { location = location, type_id = type_id, - variant_ix = variant_ix, + variant_id = variant_id, crossing_cost = crossing_cost, borders = borders } @@ -112,13 +114,13 @@ error_tile_instance : Int -> Int -> Instance error_tile_instance x y = { location = {x = x, y = y}, - type_id = 0, - variant_ix = 0, + type_id = "0", + variant_id = "0", crossing_cost = Constants.Movement.cost_when_out_of_bounds, borders = [] } -get_id : Type -> Int +get_id : Type -> Ref get_id tile = tile.id get_cost : Type -> Int @@ -133,20 +135,20 @@ get_name tile = tile.name get_location : Instance -> Struct.Location.Type get_location tile_inst = tile_inst.location -get_type_id : Instance -> Int +get_type_id : Instance -> Ref get_type_id tile_inst = tile_inst.type_id -get_border_type_id : Border -> Int +get_border_type_id : Border -> Ref get_border_type_id tile_border = tile_border.type_id get_borders : Instance -> (List Border) get_borders tile_inst = tile_inst.borders -get_variant_ix : Instance -> Int -get_variant_ix tile_inst = tile_inst.variant_ix +get_variant_id : Instance -> VariantID +get_variant_id tile_inst = tile_inst.variant_id -get_border_variant_ix : Border -> Int -get_border_variant_ix tile_border = tile_border.variant_ix +get_border_variant_id : Border -> VariantID +get_border_variant_id tile_border = tile_border.variant_id get_local_variant_ix : Instance -> Int get_local_variant_ix tile_inst = @@ -162,7 +164,7 @@ get_local_variant_ix tile_inst = get_omnimods : Type -> Struct.Omnimods.Type get_omnimods t = t.omnimods -solve_tile_instance : (Dict.Dict Int Type) -> Instance -> Instance +solve_tile_instance : (Dict.Dict Ref Type) -> Instance -> Instance solve_tile_instance tiles tile_instance = case (Dict.get tile_instance.type_id tiles) of (Just tile) -> @@ -178,7 +180,7 @@ decoder : (Json.Decode.Decoder Type) decoder = (Json.Decode.Pipeline.decode Type - |> (Json.Decode.Pipeline.required "id" Json.Decode.int) + |> (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 "omni" Struct.Omnimods.decoder) |