summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/battle')
-rw-r--r-- | src/battle/src/Comm/AddChar.elm | 9 | ||||
-rw-r--r-- | src/battle/src/Comm/SetMap.elm | 12 | ||||
-rw-r--r-- | src/battle/src/Struct/Armor.elm | 10 | ||||
-rw-r--r-- | src/battle/src/Struct/Character.elm | 31 | ||||
-rw-r--r-- | src/battle/src/Struct/Map.elm | 4 | ||||
-rw-r--r-- | src/battle/src/Struct/ServerReply.elm | 8 | ||||
-rw-r--r-- | src/battle/src/Struct/Tile.elm | 54 | ||||
-rw-r--r-- | src/battle/src/Struct/Weapon.elm | 14 | ||||
-rw-r--r-- | src/battle/src/Update/HandleServerReply.elm | 7 | ||||
-rw-r--r-- | src/battle/src/View/Map/Tile.elm | 10 |
10 files changed, 97 insertions, 62 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)" ) ) |