| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-11-15 19:04:47 +0100 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-11-15 19:04:47 +0100 | 
| commit | 5e06809bc6e4eb9f007bf2b0dd2fd53cde600611 (patch) | |
| tree | c1988d11b3dd2b9b8e31e584c2b73aa8d106f757 /src | |
| parent | 0e0738794535add036274aa4c43a74f247add899 (diff) | |
[Untested][Out-of-sync] Use Strings for IDs.
Diffstat (limited to 'src')
24 files changed, 242 insertions, 186 deletions
| diff --git a/src/battle/src/Comm/AddChar.elm b/src/battle/src/Comm/AddChar.elm index 32227a8..184c588 100644 --- a/src/battle/src/Comm/AddChar.elm +++ b/src/battle/src/Comm/AddChar.elm @@ -5,6 +5,8 @@ import Json.Decode  -- Map -------------------------------------------------------------------  import Struct.Character +import Struct.Weapon +import Struct.Armor  import Struct.ServerReply  -------------------------------------------------------------------------------- @@ -16,7 +18,12 @@ import Struct.ServerReply  --------------------------------------------------------------------------------  internal_decoder : ( -      (Struct.Character.Type, Int, Int, Int) -> +      ( +         Struct.Character.Type, +         Struct.Weapon.Ref, +         Struct.Weapon.Ref, +         Struct.Armor.Ref +      ) ->        Struct.ServerReply.Type     )  internal_decoder char_and_refs = (Struct.ServerReply.AddCharacter char_and_refs) diff --git a/src/battle/src/Comm/SetMap.elm b/src/battle/src/Comm/SetMap.elm index d26ca74..81a4a73 100644 --- a/src/battle/src/Comm/SetMap.elm +++ b/src/battle/src/Comm/SetMap.elm @@ -17,14 +17,14 @@ type alias MapData =     {        w : Int,        h : Int, -      t : (List (List Int)) +      t : (List (List String))     }  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  --------------------------------------------------------------------------------  deserialize_tile_borders : ( -      (List Int) -> +      (List String) ->        (List Struct.Tile.Border) ->        (List Struct.Tile.Border)     ) @@ -39,7 +39,7 @@ deserialize_tile_borders rem_ints current_borders =        _ -> [] -deserialize_tile_instance : Int -> Int -> (List Int) -> Struct.Tile.Instance +deserialize_tile_instance : Int -> Int -> (List String) -> Struct.Tile.Instance  deserialize_tile_instance map_width index t =     case t of        (a :: (b :: c)) -> @@ -60,8 +60,8 @@ deserialize_tile_instance map_width index t =                 x = (index % map_width),                 y = (index // map_width)              } -            0 -            0 +            "0" +            "0"              Constants.Movement.cost_when_out_of_bounds              []           ) @@ -91,7 +91,7 @@ decode =           (Json.Decode.field "h" Json.Decode.int)           (Json.Decode.field              "t" -            (Json.Decode.list (Json.Decode.list Json.Decode.int)) +            (Json.Decode.list (Json.Decode.list Json.Decode.string))           )        )     ) diff --git a/src/battle/src/Struct/Armor.elm b/src/battle/src/Struct/Armor.elm index 659f2c3..cc512e0 100644 --- a/src/battle/src/Struct/Armor.elm +++ b/src/battle/src/Struct/Armor.elm @@ -23,12 +23,12 @@ import Struct.Omnimods  --------------------------------------------------------------------------------  type alias Type =     { -      id : Int, +      id : String,        name : String,        omnimods : Struct.Omnimods.Type     } -type alias Ref = Int +type alias Ref = String  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -37,7 +37,7 @@ type alias Ref = Int  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Struct.Omnimods.Type -> Type +new : String -> String -> Struct.Omnimods.Type -> Type  new id name omnimods =     {        id = id, @@ -61,10 +61,10 @@ 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 "omni" Struct.Omnimods.decoder)     )  none : Type -none = (new 0 "None" (Struct.Omnimods.new [] [] [] [])) +none = (new "0" "None" (Struct.Omnimods.new [] [] [] [])) diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index b837962..b4d3917 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -58,9 +58,9 @@ type alias PartiallyDecoded =        pla : Int,        ena : Bool,        dea : Bool, -      awp : Int, -      swp : Int, -      ar : Int, +      awp : Struct.Weapon.Ref, +      swp : Struct.Weapon.Ref, +      ar : Struct.Armor.Ref,        omni : Struct.Omnimods.Type     } @@ -99,7 +99,15 @@ str_to_rank str =        "c" -> Commander        _ -> Optional -finish_decoding : PartiallyDecoded -> (Type, Int, Int, Int) +finish_decoding : ( +      PartiallyDecoded -> +      ( +         Type, +         Struct.Weapon.Ref, +         Struct.Weapon.Ref, +         Struct.Armor.Ref +      ) +   )  finish_decoding add_char =     let        weapon_set = (Struct.WeaponSet.new Struct.Weapon.none Struct.Weapon.none) @@ -207,7 +215,14 @@ set_weapons weapons char =        weapons = weapons     } -decoder : (Json.Decode.Decoder (Type, Int, Int, Int)) +decoder : (Json.Decode.Decoder +      ( +         Type, +         Struct.Weapon.Ref, +         Struct.Weapon.Ref, +         Struct.Armor.Ref +      ) +   )  decoder =     (Json.Decode.map        (finish_decoding) @@ -223,9 +238,9 @@ decoder =           |> (Json.Decode.Pipeline.required "pla" Json.Decode.int)           |> (Json.Decode.Pipeline.required "ena" Json.Decode.bool)           |> (Json.Decode.Pipeline.required "dea" Json.Decode.bool) -         |> (Json.Decode.Pipeline.required "awp" Json.Decode.int) -         |> (Json.Decode.Pipeline.required "swp" Json.Decode.int) -         |> (Json.Decode.Pipeline.required "ar" Json.Decode.int) +         |> (Json.Decode.Pipeline.required "awp" Json.Decode.string) +         |> (Json.Decode.Pipeline.required "swp" Json.Decode.string) +         |> (Json.Decode.Pipeline.required "ar" Json.Decode.string)           |> (Json.Decode.Pipeline.required "pomni" Struct.Omnimods.decoder)        )     ) diff --git a/src/battle/src/Struct/Map.elm b/src/battle/src/Struct/Map.elm index 5f87f1f..8c2491d 100644 --- a/src/battle/src/Struct/Map.elm +++ b/src/battle/src/Struct/Map.elm @@ -120,7 +120,7 @@ get_movement_cost_function bmap start_loc char_list loc =     else        Constants.Movement.cost_when_out_of_bounds -solve_tiles : (Dict.Dict Int Struct.Tile.Type) -> Type -> Type +solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type  solve_tiles tiles bmap =     {bmap |        content = (Array.map (Struct.Tile.solve_tile_instance tiles) bmap.content) @@ -128,7 +128,7 @@ solve_tiles tiles bmap =  get_omnimods_at : (        Struct.Location.Type -> -      (Dict.Dict Int Struct.Tile.Type) -> +      (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) ->        Type ->        Struct.Omnimods.Type     ) diff --git a/src/battle/src/Struct/ServerReply.elm b/src/battle/src/Struct/ServerReply.elm index 28dde0d..881be78 100644 --- a/src/battle/src/Struct/ServerReply.elm +++ b/src/battle/src/Struct/ServerReply.elm @@ -19,7 +19,13 @@ type Type =     | Disconnected     | AddArmor Struct.Armor.Type     | AddWeapon Struct.Weapon.Type -   | AddCharacter (Struct.Character.Type, Int, Int, Int) +   | AddCharacter +      ( +         Struct.Character.Type, +         Struct.Weapon.Ref, +         Struct.Weapon.Ref, +         Struct.Armor.Ref +      )     | AddTile Struct.Tile.Type     | SetMap Struct.Map.Type     | TurnResults (List Struct.TurnResult.Type) 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) diff --git a/src/battle/src/Struct/Weapon.elm b/src/battle/src/Struct/Weapon.elm index 2035fe4..0709318 100644 --- a/src/battle/src/Struct/Weapon.elm +++ b/src/battle/src/Struct/Weapon.elm @@ -25,7 +25,7 @@ import Struct.Omnimods  --------------------------------------------------------------------------------  type alias PartiallyDecoded =     { -      id : Int, +      id : String,        nam : String,        rmi : Int,        rma : Int, @@ -34,7 +34,7 @@ type alias PartiallyDecoded =  type alias Type =     { -      id : Int, +      id : String,        name : String,        def_range : Int,        atk_range : Int, @@ -42,7 +42,7 @@ type alias Type =        damage_sum : Int     } -type alias Ref = Int +type alias Ref = String  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -51,7 +51,7 @@ type alias Ref = Int  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Int -> Int -> Struct.Omnimods.Type -> Type +new : String -> String -> Int -> Int -> Struct.Omnimods.Type -> Type  new id name range_min range_max omnimods =     {        id = id, @@ -62,7 +62,7 @@ new id name range_min range_max omnimods =        damage_sum = (Struct.Omnimods.get_damage_sum omnimods)     } -get_id : Type -> Int +get_id : Type -> String  get_id wp = wp.id  get_name : Type -> String @@ -86,7 +86,7 @@ decoder =        (\e -> {e | damage_sum = (Struct.Omnimods.get_damage_sum e.omnimods)})        (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 "rmi" Json.Decode.int)           |> (Json.Decode.Pipeline.required "rma" Json.Decode.int) @@ -96,4 +96,4 @@ decoder =     )  none : Type -none = (new 0 "None" 0 0 (Struct.Omnimods.new [] [] [] [])) +none = (new "0" "None" 0 0 (Struct.Omnimods.new [] [] [] [])) diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index b1506ba..ef1ed73 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -106,7 +106,12 @@ add_weapon wp current_state =        ((Struct.Model.add_weapon wp model), cmds)  add_character : ( -      (Struct.Character.Type, Int, Int, Int) -> +      ( +         Struct.Character.Type, +         Struct.Weapon.Ref, +         Struct.Weapon.Ref, +         Struct.Armor.Ref +      ) ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->        (Struct.Model.Type, (List (Cmd Struct.Event.Type)))     ) diff --git a/src/battle/src/View/Map/Tile.elm b/src/battle/src/View/Map/Tile.elm index 962b998..7bccf98 100644 --- a/src/battle/src/View/Map/Tile.elm +++ b/src/battle/src/View/Map/Tile.elm @@ -32,9 +32,9 @@ get_layer_html index border =                    (                       "url("                       ++ Constants.IO.tile_assets_url -                     ++ (toString (Struct.Tile.get_border_type_id border)) +                     ++ (Struct.Tile.get_border_type_id border)                       ++ "-f-" -                     ++ (toString (Struct.Tile.get_border_variant_ix border)) +                     ++ (Struct.Tile.get_border_variant_id border)                       ++ ".svg)"                    )                 ) @@ -60,7 +60,7 @@ get_content_html tile =                       (                          "url("                          ++ Constants.IO.tile_assets_url -                        ++ (toString (Struct.Tile.get_type_id tile)) +                        ++ (Struct.Tile.get_type_id tile)                          ++ "-bg.svg)"                       )                    ) @@ -81,9 +81,9 @@ get_content_html tile =                          (                             "url("                             ++ Constants.IO.tile_assets_url -                           ++ (toString (Struct.Tile.get_type_id tile)) +                           ++ (Struct.Tile.get_type_id tile)                             ++ "-v-" -                           ++ (toString (Struct.Tile.get_variant_ix tile)) +                           ++ (Struct.Tile.get_variant_id tile)                             ++ ".svg)"                          )                       ) diff --git a/src/map-editor/src/Comm/SendMapUpdate.elm b/src/map-editor/src/Comm/SendMapUpdate.elm index d47cee2..0a2b7da 100644 --- a/src/map-editor/src/Comm/SendMapUpdate.elm +++ b/src/map-editor/src/Comm/SendMapUpdate.elm @@ -25,8 +25,8 @@ import Struct.Tile  encode_tile_border_values : Struct.Tile.Border -> (List Json.Encode.Value)  encode_tile_border_values border =     [ -      (Json.Encode.int (Struct.Tile.get_border_type_id border)), -      (Json.Encode.int (Struct.Tile.get_border_variant_ix border)) +      (Json.Encode.string (Struct.Tile.get_border_type_id border)), +      (Json.Encode.string (Struct.Tile.get_border_variant_id border))     ]  encode_tile_instance : Struct.Tile.Instance -> Json.Encode.Value @@ -34,8 +34,8 @@ encode_tile_instance tile_inst =     (Json.Encode.list        (           [ -            (Json.Encode.int (Struct.Tile.get_type_id tile_inst)), -            (Json.Encode.int (Struct.Tile.get_variant_ix tile_inst)) +            (Json.Encode.string (Struct.Tile.get_type_id tile_inst)), +            (Json.Encode.string (Struct.Tile.get_variant_id tile_inst))           ]           ++           (List.concatMap diff --git a/src/map-editor/src/Comm/SetMap.elm b/src/map-editor/src/Comm/SetMap.elm index 36ddade..171ed34 100644 --- a/src/map-editor/src/Comm/SetMap.elm +++ b/src/map-editor/src/Comm/SetMap.elm @@ -17,14 +17,14 @@ type alias MapData =     {        w : Int,        h : Int, -      t : (List (List Int)) +      t : (List (List String))     }  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  --------------------------------------------------------------------------------  deserialize_tile_borders : ( -      (List Int) -> +      (List String) ->        (List Struct.Tile.Border) ->        (List Struct.Tile.Border)     ) @@ -39,7 +39,12 @@ deserialize_tile_borders rem_ints current_borders =        _ -> [] -deserialize_tile_instance : Int -> Int -> (List Int) -> Struct.Tile.Instance +deserialize_tile_instance : ( +      Int -> +      Int -> +      (List String) -> +      Struct.Tile.Instance +   )  deserialize_tile_instance map_width index t =     case t of        (a :: (b :: c)) -> @@ -51,7 +56,7 @@ deserialize_tile_instance map_width index t =              a              b              Constants.Movement.cost_when_out_of_bounds -            -1 +            "-1"              (deserialize_tile_borders c [])           ) @@ -61,10 +66,10 @@ deserialize_tile_instance map_width index t =                 x = (index % map_width),                 y = (index // map_width)              } -            0 -            0 +            "0" +            "0"              Constants.Movement.cost_when_out_of_bounds -            -1 +            "-1"              []           ) @@ -93,7 +98,7 @@ decode =           (Json.Decode.field "h" Json.Decode.int)           (Json.Decode.field              "t" -            (Json.Decode.list (Json.Decode.list Json.Decode.int)) +            (Json.Decode.list (Json.Decode.list Json.Decode.string))           )        )     ) diff --git a/src/map-editor/src/Struct/Event.elm b/src/map-editor/src/Struct/Event.elm index 449f590..6d22666 100644 --- a/src/map-editor/src/Struct/Event.elm +++ b/src/map-editor/src/Struct/Event.elm @@ -8,6 +8,7 @@ import Struct.Error  import Struct.HelpRequest  import Struct.Location  import Struct.ServerReply +import Struct.Tile  import Struct.Toolbox  import Struct.UI @@ -25,7 +26,7 @@ type Type =     | ModeRequested Struct.Toolbox.Mode     | ShapeRequested Struct.Toolbox.Shape     | ClearSelectionRequested -   | TemplateRequested (Int, Int) +   | TemplateRequested (Struct.Tile.Ref, Struct.Tile.VariantID)     | PrettifySelectionRequested     | SendMapUpdateRequested     | GoToMainMenu diff --git a/src/map-editor/src/Struct/Map.elm b/src/map-editor/src/Struct/Map.elm index ca16a4c..a00bba2 100644 --- a/src/map-editor/src/Struct/Map.elm +++ b/src/map-editor/src/Struct/Map.elm @@ -90,7 +90,7 @@ try_getting_tile_at loc map =     then (Array.get (location_to_index loc map) map.content)     else Nothing -solve_tiles : (Dict.Dict Int Struct.Tile.Type) -> Type -> Type +solve_tiles : (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> Type -> Type  solve_tiles tiles map =     {map |        content = (Array.map (Struct.Tile.solve_tile_instance tiles) map.content) diff --git a/src/map-editor/src/Struct/Model.elm b/src/map-editor/src/Struct/Model.elm index a7ec964..7b04aa8 100644 --- a/src/map-editor/src/Struct/Model.elm +++ b/src/map-editor/src/Struct/Model.elm @@ -33,7 +33,11 @@ type alias Type =        toolbox: Struct.Toolbox.Type,        help_request: Struct.HelpRequest.Type,        map: Struct.Map.Type, -      tile_patterns: (Dict.Dict String Int), +      tile_patterns: +         (Dict.Dict +            Struct.TilePattern.Actual +            Struct.Tile.VariantID +         ),        wild_tile_patterns: (List Struct.TilePattern.Type),        tiles: (Dict.Dict Struct.Tile.Ref Struct.Tile.Type),        error: (Maybe Struct.Error.Type), @@ -107,7 +111,7 @@ add_tile_pattern tp model =           tile_patterns =              (Dict.insert                 (Struct.TilePattern.get_pattern tp) -               (Struct.TilePattern.get_variant tp) +               (Struct.TilePattern.get_variant_id tp)                 model.tile_patterns              )        } diff --git a/src/map-editor/src/Struct/Tile.elm b/src/map-editor/src/Struct/Tile.elm index 1534d26..2b33ed0 100644 --- a/src/map-editor/src/Struct/Tile.elm +++ b/src/map-editor/src/Struct/Tile.elm @@ -1,6 +1,8 @@  module Struct.Tile exposing     (        Ref, +      VariantID, +      FamilyID,        Type,        Instance,        Border, @@ -14,14 +16,14 @@ module Struct.Tile exposing        set_borders,        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_family,        get_instance_family, -      get_variant_ix, +      get_variant_id,        get_local_variant_ix,        solve_tile_instance,        decoder @@ -42,39 +44,41 @@ import Struct.Location  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- -type alias Ref = Int +type alias Ref = String +type alias VariantID = String +type alias FamilyID = String  type alias PartiallyDecoded =     { -      id : Int, +      id : Ref,        nam : String,        ct : Int, -      fa : Int, +      fa : FamilyID,        de : Int     }  type alias Type =     { -      id : Int, +      id : Ref,        name : String,        crossing_cost : Int, -      family : Int, +      family : FamilyID,        depth : Int     }  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, -      family : Int, -      type_id : Int, -      variant_ix : Int, +      family : FamilyID, +      type_id : Ref, +      variant_id : VariantID,        borders : (List Border)     } @@ -112,7 +116,7 @@ finish_decoding add_tile =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Int -> Int -> Int -> Type +new : Ref -> String -> Int -> FamilyID -> Int -> Type  new id name crossing_cost family depth =     {        id = id, @@ -125,27 +129,27 @@ new id name crossing_cost family depth =  clone_instance : Struct.Location.Type -> Instance -> Instance  clone_instance loc inst = {inst | location = loc} -new_border : Int -> Int -> Border -new_border type_id variant_ix = +new_border : Ref -> VariantID -> Border +new_border type_id variant_id =     {        type_id = type_id, -      variant_ix = variant_ix +      variant_id = variant_id     }  new_instance : (        Struct.Location.Type -> +      Ref -> +      VariantID ->        Int -> -      Int -> -      Int -> -      Int -> +      FamilyID ->        (List Border) ->        Instance     ) -new_instance location type_id variant_ix crossing_cost family borders = +new_instance location type_id variant_id crossing_cost family borders =     {        location = location,        type_id = type_id, -      variant_ix = variant_ix, +      variant_id = variant_id,        crossing_cost = crossing_cost,        family = family,        borders = borders @@ -155,14 +159,14 @@ error_tile_instance : Int -> Int -> Instance  error_tile_instance x y =     {        location = {x = x, y = y}, -      type_id = 0, -      variant_ix = 0, -      family = 0, +      type_id = "0", +      variant_id = "0", +      family = "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 @@ -177,13 +181,13 @@ 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_family : Type -> Int +get_family : Type -> FamilyID  get_family tile = tile.family  set_borders : (List Border) -> Instance -> Instance @@ -192,14 +196,14 @@ set_borders borders tile_inst = {tile_inst | borders = borders}  get_borders : Instance -> (List Border)  get_borders tile_inst = tile_inst.borders -get_instance_family : Instance -> Int +get_instance_family : Instance -> FamilyID  get_instance_family tile_inst = tile_inst.family -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 = @@ -212,7 +216,7 @@ get_local_variant_ix tile_inst =        % Constants.UI.local_variants_per_tile     ) -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) -> @@ -224,7 +228,7 @@ solve_tile_instance tiles tile_instance =        Nothing ->           {tile_instance |              crossing_cost = -1, -            family = -1 +            family = "-1"           }  decoder : (Json.Decode.Decoder Type) @@ -233,10 +237,10 @@ decoder =        (finish_decoding)        (Json.Decode.Pipeline.decode           PartiallyDecoded -         |> (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 "fa" Json.Decode.int) +         |> (Json.Decode.Pipeline.required "fa" Json.Decode.string)           |> (Json.Decode.Pipeline.required "de" Json.Decode.int)        )     ) diff --git a/src/map-editor/src/Struct/TilePattern.elm b/src/map-editor/src/Struct/TilePattern.elm index 7c9279e..6e2e202 100644 --- a/src/map-editor/src/Struct/TilePattern.elm +++ b/src/map-editor/src/Struct/TilePattern.elm @@ -1,11 +1,12 @@  module Struct.TilePattern exposing     (        Type, +      Actual,        decoder,        get_pattern_for,        patterns_match,        get_pattern, -      get_variant, +      get_variant_id,        is_wild     ) @@ -21,11 +22,13 @@ import Struct.Tile  --------------------------------------------------------------------------------  -- TYPES -----------------------------------------------------------------------  -------------------------------------------------------------------------------- +type alias Actual = String +  type alias Type =     { -      v : Int, +      v : Struct.Tile.VariantID,        w : Bool, -      p : String +      p : Actual     }  -------------------------------------------------------------------------------- @@ -35,14 +38,14 @@ type alias Type =  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -get_pattern_for : Int -> (List Struct.Tile.Instance) -> String +get_pattern_for : Struct.Tile.FamilyID -> (List Struct.Tile.Instance) -> Actual  get_pattern_for source_fa neighborhood =     (List.foldl        (\t -> \acc ->           let              t_fa = (Struct.Tile.get_instance_family t)           in -            if ((t_fa == -1) || (t_fa == source_fa)) +            if ((t_fa == "-1") || (t_fa == source_fa))              then (acc ++ "1")              else (acc ++ "0")        ) @@ -50,7 +53,7 @@ get_pattern_for source_fa neighborhood =        neighborhood     ) -patterns_match : String -> String -> Bool +patterns_match : Actual -> Actual -> Bool  patterns_match a b =     case ((String.uncons a), (String.uncons b)) of        (Nothing, _) -> True @@ -61,11 +64,11 @@ patterns_match a b =        (_, _) -> False -get_pattern : Type -> String +get_pattern : Type -> Actual  get_pattern tp = tp.p -get_variant : Type -> Int -get_variant tp = tp.v +get_variant_id : Type -> Struct.Tile.VariantID +get_variant_id tp = tp.v  is_wild : Type -> Bool  is_wild tp = tp.w @@ -74,7 +77,7 @@ decoder : (Json.Decode.Decoder Type)  decoder =     (Json.Decode.Pipeline.decode        Type -      |> (Json.Decode.Pipeline.required "v" (Json.Decode.int)) +      |> (Json.Decode.Pipeline.required "v" (Json.Decode.string))        |> (Json.Decode.Pipeline.required "w" (Json.Decode.bool))        |> (Json.Decode.Pipeline.required "p" (Json.Decode.string))     ) diff --git a/src/map-editor/src/Update/PrettifySelectedTiles.elm b/src/map-editor/src/Update/PrettifySelectedTiles.elm index dd89ea1..ef62479 100644 --- a/src/map-editor/src/Update/PrettifySelectedTiles.elm +++ b/src/map-editor/src/Update/PrettifySelectedTiles.elm @@ -34,7 +34,11 @@ neighborhood_tile_instances loc map =        (Struct.Location.get_full_neighborhood loc)     ) -get_nigh_patterns : Int -> (List Struct.Tile.Instance) -> (List (Int, Int)) +get_nigh_patterns : ( +      Struct.Tile.FamilyID -> +      (List Struct.Tile.Instance) -> +      (List (Struct.Tile.FamilyID, Struct.Tile.Ref)) +   )  get_nigh_patterns source_fm full_neighborhood =     (Set.toList        (List.foldl @@ -61,7 +65,7 @@ get_nigh_patterns source_fm full_neighborhood =  nigh_pattern_to_border : (        Struct.Model.Type ->        (List Struct.Tile.Instance) -> -      (Int, Int) -> +      (Struct.Tile.FamilyID, Struct.Tile.Ref) ->        (Struct.Tile.Border)     )  nigh_pattern_to_border model full_neighborhood nigh_pattern = @@ -82,11 +86,11 @@ nigh_pattern_to_border model full_neighborhood nigh_pattern =                    model.wild_tile_patterns                 )              of -               Nothing -> (Struct.Tile.new_border 0 0) +               Nothing -> (Struct.Tile.new_border "0" "0")                 (Just tp) ->                    (Struct.Tile.new_border                       tid -                     (Struct.TilePattern.get_variant tp) +                     (Struct.TilePattern.get_variant_id tp)                    )           (Just v) -> (Struct.Tile.new_border tid v) diff --git a/src/map-editor/src/Update/SetToolboxTemplate.elm b/src/map-editor/src/Update/SetToolboxTemplate.elm index cb7b783..4a0593d 100644 --- a/src/map-editor/src/Update/SetToolboxTemplate.elm +++ b/src/map-editor/src/Update/SetToolboxTemplate.elm @@ -16,11 +16,11 @@ import Struct.Model  --------------------------------------------------------------------------------  apply_to : (        Struct.Model.Type -> -      Int -> -      Int -> +      String -> +      String ->        (Struct.Model.Type, (Cmd Struct.Event.Type))     ) -apply_to model main_class variant_ix = +apply_to model main_class_id variant_id =     (        {model |           toolbox = @@ -29,10 +29,10 @@ apply_to model main_class variant_ix =                    model.tiles                    (Struct.Tile.new_instance                       {x = 0, y = 0} -                     main_class -                     variant_ix -                     0 +                     main_class_id +                     variant_id                       0 +                     "0"                       []                    )                 ) diff --git a/src/map-editor/src/View/Map/Tile.elm b/src/map-editor/src/View/Map/Tile.elm index bd3bc81..32f536c 100644 --- a/src/map-editor/src/View/Map/Tile.elm +++ b/src/map-editor/src/View/Map/Tile.elm @@ -33,9 +33,9 @@ get_layer_html index border =                    (                       "url("                       ++ Constants.IO.tile_assets_url -                     ++ (toString (Struct.Tile.get_border_type_id border)) +                     ++ (Struct.Tile.get_border_type_id border)                       ++ "-f-" -                     ++ (toString (Struct.Tile.get_border_variant_ix border)) +                     ++ (Struct.Tile.get_border_variant_id border)                       ++ ".svg)"                    )                 ) @@ -61,7 +61,7 @@ get_content_html tile =                       (                          "url("                          ++ Constants.IO.tile_assets_url -                        ++ (toString (Struct.Tile.get_type_id tile)) +                        ++ (Struct.Tile.get_type_id tile)                          ++ "-bg.svg)"                       )                    ) @@ -82,9 +82,9 @@ get_content_html tile =                          (                             "url("                             ++ Constants.IO.tile_assets_url -                           ++ (toString (Struct.Tile.get_type_id tile)) +                           ++ (Struct.Tile.get_type_id tile)                             ++ "-v-" -                           ++ (toString (Struct.Tile.get_variant_ix tile)) +                           ++ (Struct.Tile.get_variant_id tile)                             ++ ".svg)"                          )                       ) diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm index c2bb171..591b312 100644 --- a/src/map-editor/src/View/SubMenu/Tiles.elm +++ b/src/map-editor/src/View/SubMenu/Tiles.elm @@ -14,30 +14,30 @@ import View.Map.Tile  --------------------------------------------------------------------------------  -- LOCAL -----------------------------------------------------------------------  -------------------------------------------------------------------------------- --- TODO: display and allow selection of all variations.  get_icon_html : Int -> (Html.Html Struct.Event.Type) -get_icon_html icon_id = -   (Html.div -      [ -         (Html.Attributes.class "map-tile"), -         (Html.Attributes.class "map-tiled"), -         (Html.Attributes.class "clickable"), -         (Html.Attributes.class "map-tile-variant-0"), -         (Html.Events.onClick -            (Struct.Event.TemplateRequested (icon_id, 0)) -         ) -      ] -      (View.Map.Tile.get_content_html -         (Struct.Tile.new_instance -            {x = 0, y = 0} -            icon_id -            0 -            0 -            0 -            [] +get_icon_html index = +   let tile_id = (toString index) in +      (Html.div +         [ +            (Html.Attributes.class "map-tile"), +            (Html.Attributes.class "map-tiled"), +            (Html.Attributes.class "clickable"), +            (Html.Attributes.class "map-tile-variant-0"), +            (Html.Events.onClick +               (Struct.Event.TemplateRequested (tile_id, "0")) +            ) +         ] +         (View.Map.Tile.get_content_html +            (Struct.Tile.new_instance +               {x = 0, y = 0} +               tile_id +               "0" +               0 +               "0" +               [] +            )           )        ) -   )  --------------------------------------------------------------------------------  -- EXPORTED -------------------------------------------------------------------- diff --git a/src/roster-editor/src/Struct/Armor.elm b/src/roster-editor/src/Struct/Armor.elm index 5f163fe..6bae44f 100644 --- a/src/roster-editor/src/Struct/Armor.elm +++ b/src/roster-editor/src/Struct/Armor.elm @@ -24,12 +24,12 @@ import Struct.Omnimods  --------------------------------------------------------------------------------  type alias Type =     { -      id : Int, +      id : String,        name : String,        omnimods : Struct.Omnimods.Type     } -type alias Ref = Int +type alias Ref = String  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -38,7 +38,7 @@ type alias Ref = Int  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Struct.Omnimods.Type -> Type +new : String -> String -> Struct.Omnimods.Type -> Type  new id name omnimods =     {        id = id, @@ -53,7 +53,7 @@ get_name : Type -> String  get_name ar = ar.name  get_image_id : Type -> String -get_image_id ar = (toString ar.id) +get_image_id ar = ar.id  get_omnimods : Type -> Struct.Omnimods.Type  get_omnimods ar = ar.omnimods @@ -62,13 +62,13 @@ 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 "omni" Struct.Omnimods.decoder)     )  none : Type -none = (new 0 "None" (Struct.Omnimods.new [] [] [] [])) +none = (new "0" "None" (Struct.Omnimods.none))  default : Type  default = (none) diff --git a/src/roster-editor/src/Struct/CharacterRecord.elm b/src/roster-editor/src/Struct/CharacterRecord.elm index 0807aed..62bfa93 100644 --- a/src/roster-editor/src/Struct/CharacterRecord.elm +++ b/src/roster-editor/src/Struct/CharacterRecord.elm @@ -38,9 +38,9 @@ type alias Type =        index : Int,        name : String,        portrait_id : String, -      main_weapon_id : Int, -      secondary_weapon_id : Int, -      armor_id : Int, +      main_weapon_id : String, +      secondary_weapon_id : String, +      armor_id : String,        glyph_board_id : String,        glyph_ids : (List String)     } @@ -61,13 +61,13 @@ get_name c = c.name  get_portrait_id : Type -> String  get_portrait_id c = c.portrait_id -get_main_weapon_id : Type -> Int +get_main_weapon_id : Type -> String  get_main_weapon_id char = char.main_weapon_id -get_secondary_weapon_id : Type -> Int +get_secondary_weapon_id : Type -> String  get_secondary_weapon_id char = char.secondary_weapon_id -get_armor_id : Type -> Int +get_armor_id : Type -> String  get_armor_id char = char.armor_id  get_glyph_board_id : Type -> String @@ -109,9 +109,9 @@ decoder =        |> (Json.Decode.Pipeline.required "ix" Json.Decode.int)        |> (Json.Decode.Pipeline.required "nam" Json.Decode.string)        |> (Json.Decode.Pipeline.required "prt" Json.Decode.string) -      |> (Json.Decode.Pipeline.required "awp" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "swp" Json.Decode.int) -      |> (Json.Decode.Pipeline.required "ar" Json.Decode.int) +      |> (Json.Decode.Pipeline.required "awp" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "swp" Json.Decode.string) +      |> (Json.Decode.Pipeline.required "ar" Json.Decode.string)        |> (Json.Decode.Pipeline.required "gb" Json.Decode.string)        |> (Json.Decode.Pipeline.required              "gls" @@ -126,9 +126,9 @@ encode char =           ("ix", (Json.Encode.int char.index)),           ("nam", (Json.Encode.string char.name)),           ("prt", (Json.Encode.string char.portrait_id)), -         ("awp", (Json.Encode.int char.main_weapon_id)), -         ("swp", (Json.Encode.int char.secondary_weapon_id)), -         ("ar", (Json.Encode.int char.armor_id)), +         ("awp", (Json.Encode.string char.main_weapon_id)), +         ("swp", (Json.Encode.string char.secondary_weapon_id)), +         ("ar", (Json.Encode.string char.armor_id)),           ("gb", (Json.Encode.string char.glyph_board_id)),           (              "gls", diff --git a/src/roster-editor/src/Struct/Weapon.elm b/src/roster-editor/src/Struct/Weapon.elm index eb1f2e4..3556533 100644 --- a/src/roster-editor/src/Struct/Weapon.elm +++ b/src/roster-editor/src/Struct/Weapon.elm @@ -26,7 +26,7 @@ import Struct.Omnimods  --------------------------------------------------------------------------------  type alias PartiallyDecoded =     { -      id : Int, +      id : String,        nam : String,        rmi : Int,        rma : Int, @@ -35,7 +35,7 @@ type alias PartiallyDecoded =  type alias Type =     { -      id : Int, +      id : String,        name : String,        def_range : Int,        atk_range : Int, @@ -43,7 +43,7 @@ type alias Type =        damage_sum : Int     } -type alias Ref = Int +type alias Ref = String  --------------------------------------------------------------------------------  -- LOCAL ----------------------------------------------------------------------- @@ -52,7 +52,7 @@ type alias Ref = Int  --------------------------------------------------------------------------------  -- EXPORTED --------------------------------------------------------------------  -------------------------------------------------------------------------------- -new : Int -> String -> Int -> Int -> Struct.Omnimods.Type -> Type +new : String -> String -> Int -> Int -> Struct.Omnimods.Type -> Type  new id name range_min range_max omnimods =     {        id = id, @@ -63,7 +63,7 @@ new id name range_min range_max omnimods =        damage_sum = (Struct.Omnimods.get_damage_sum omnimods)     } -get_id : Type -> Int +get_id : Type -> String  get_id wp = wp.id  get_name : Type -> String @@ -87,7 +87,7 @@ decoder =        (\e -> {e | damage_sum = (Struct.Omnimods.get_damage_sum e.omnimods)})        (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 "rmi" Json.Decode.int)           |> (Json.Decode.Pipeline.required "rma" Json.Decode.int) @@ -97,7 +97,7 @@ decoder =     )  none : Type -none = (new 0 "None" 0 0 (Struct.Omnimods.none)) +none = (new "0" "None" 0 0 (Struct.Omnimods.none))  default : Type  default = (none) | 


