From c1066323a777d14de4070b0bb8de2c248711285f Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Thu, 17 Jan 2019 15:45:56 +0100 Subject: ... Starting to get "elm: not enough bytes" errors. --- src/battle/src/Action/Scroll.elm | 2 +- src/battle/src/Comm/AddChar.elm | 7 +---- src/battle/src/Struct/Armor.elm | 2 +- src/battle/src/Struct/Character.elm | 36 +++++++++++++------------- src/battle/src/Struct/Event.elm | 8 +++++- src/battle/src/Struct/Path.elm | 40 +++++++++++++++-------------- src/battle/src/Struct/ServerReply.elm | 8 +----- src/battle/src/Struct/Tile.elm | 4 +-- src/battle/src/Update/HandleServerReply.elm | 6 ++++- 9 files changed, 57 insertions(+), 56 deletions(-) diff --git a/src/battle/src/Action/Scroll.elm b/src/battle/src/Action/Scroll.elm index c853783..4f781eb 100755 --- a/src/battle/src/Action/Scroll.elm +++ b/src/battle/src/Action/Scroll.elm @@ -27,7 +27,7 @@ tile_to_px ui t = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -to : Struct.Location.Type -> Struct.UI.Type -> (Task.Task Browser.Dom.Error (List ())) +to : Struct.Location.Type -> Struct.UI.Type -> (Task.Task Browser.Dom.Error ()) to loc ui = (Browser.Dom.setViewportOf Constants.UI.viewer_html_id diff --git a/src/battle/src/Comm/AddChar.elm b/src/battle/src/Comm/AddChar.elm index 184c588..9c7662e 100644 --- a/src/battle/src/Comm/AddChar.elm +++ b/src/battle/src/Comm/AddChar.elm @@ -18,12 +18,7 @@ import Struct.ServerReply -------------------------------------------------------------------------------- internal_decoder : ( - ( - Struct.Character.Type, - Struct.Weapon.Ref, - Struct.Weapon.Ref, - Struct.Armor.Ref - ) -> + Struct.Character.TypeAndEquipementRef -> Struct.ServerReply.Type ) internal_decoder char_and_refs = (Struct.ServerReply.AddCharacter char_and_refs) diff --git a/src/battle/src/Struct/Armor.elm b/src/battle/src/Struct/Armor.elm index a76de34..3043526 100644 --- a/src/battle/src/Struct/Armor.elm +++ b/src/battle/src/Struct/Armor.elm @@ -52,7 +52,7 @@ get_name : Type -> String get_name ar = ar.name get_image_id : Type -> String -get_image_id ar = (String.fromInt ar.id) +get_image_id ar = ar.id get_omnimods : Type -> Struct.Omnimods.Type get_omnimods ar = ar.omnimods diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index e180fdc..322d67a 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -2,6 +2,7 @@ module Struct.Character exposing ( Type, Rank(..), + TypeAndEquipmentRef, get_index, get_player_ix, get_name, @@ -64,6 +65,7 @@ type alias PartiallyDecoded = omni : Struct.Omnimods.Type } + type Rank = Optional | Target @@ -89,6 +91,14 @@ type alias Type = permanent_omnimods : Struct.Omnimods.Type } +type alias TypeAndEquipmentRef = + { + char : Type, + main_weapon_ref : String, + secondary_weapon_ref : String, + armor_ref : String + } + -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- -------------------------------------------------------------------------------- @@ -99,15 +109,7 @@ str_to_rank str = "c" -> Commander _ -> Optional -finish_decoding : ( - PartiallyDecoded -> - ( - Type, - Struct.Weapon.Ref, - Struct.Weapon.Ref, - Struct.Armor.Ref - ) - ) +finish_decoding : PartiallyDecoded -> TypeAndEquipmentRef finish_decoding add_char = let weapon_set = (Struct.WeaponSet.new Struct.Weapon.none Struct.Weapon.none) @@ -133,7 +135,12 @@ finish_decoding add_char = permanent_omnimods = add_char.omni } in - (almost_char, add_char.awp, add_char.swp, add_char.ar) + { + char = almost_char, + main_weapon_ref = add_char.awp, + secondary_weapon_ref = add_char.swp, + armor_ref = add_char.ar + } -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- @@ -215,14 +222,7 @@ set_weapons weapons char = weapons = weapons } -decoder : (Json.Decode.Decoder - ( - Type, - Struct.Weapon.Ref, - Struct.Weapon.Ref, - Struct.Armor.Ref - ) - ) +decoder : (Json.Decode.Decoder TypeAndEquipmentRef) decoder = (Json.Decode.map (finish_decoding) diff --git a/src/battle/src/Struct/Event.elm b/src/battle/src/Struct/Event.elm index 3433c4a..83f1e97 100644 --- a/src/battle/src/Struct/Event.elm +++ b/src/battle/src/Struct/Event.elm @@ -43,4 +43,10 @@ attempted act = case act of (Result.Ok _) -> None (Result.Err msg) -> - (Failed (Struct.Error.new Struct.Error.Failure (toString msg))) + (Failed + (Struct.Error.new + Struct.Error.Failure + -- TODO: find a way to get some relevant text here. + "(text representation not implemented)" + ) + ) diff --git a/src/battle/src/Struct/Path.elm b/src/battle/src/Struct/Path.elm index 70e6980..b1a92ce 100644 --- a/src/battle/src/Struct/Path.elm +++ b/src/battle/src/Struct/Path.elm @@ -94,25 +94,27 @@ try_backtracking_to path dir location = of ( (Just (prev_dir_head, prev_dir_tail)), - (Just (prev_pts_head, prev_pts_tail)) - ) -> - if (prev_dir_head == (Struct.Direction.opposite_of dir)) - then - (Just - {path | - current_location = location, - visited_locations = - (Set.remove - (Struct.Location.get_ref location) - path.visited_locations - ), - previous_directions = prev_dir_tail, - previous_points = prev_pts_tail, - remaining_points = prev_pts_head - } - ) - else - Nothing + (Just (prev_pts_head, prev_pts_tail))) -> + -- Does not compile in Elm 0.19 if I put the closing paren on this line + ( + if (prev_dir_head == (Struct.Direction.opposite_of dir)) + then + (Just + {path | + current_location = location, + visited_locations = + (Set.remove + (Struct.Location.get_ref location) + path.visited_locations + ), + previous_directions = prev_dir_tail, + previous_points = prev_pts_tail, + remaining_points = prev_pts_head + } + ) + else + Nothing + ) (_, _) -> Nothing diff --git a/src/battle/src/Struct/ServerReply.elm b/src/battle/src/Struct/ServerReply.elm index 881be78..25a0b2f 100644 --- a/src/battle/src/Struct/ServerReply.elm +++ b/src/battle/src/Struct/ServerReply.elm @@ -19,13 +19,7 @@ type Type = | Disconnected | AddArmor Struct.Armor.Type | AddWeapon Struct.Weapon.Type - | AddCharacter - ( - Struct.Character.Type, - Struct.Weapon.Ref, - Struct.Weapon.Ref, - Struct.Armor.Ref - ) + | AddCharacter Struct.Character.TypeAndEquipmentRef | 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 a41e561..90e328f 100644 --- a/src/battle/src/Struct/Tile.elm +++ b/src/battle/src/Struct/Tile.elm @@ -152,13 +152,13 @@ get_border_variant_id tile_border = tile_border.variant_id get_local_variant_ix : Instance -> Int get_local_variant_ix tile_inst = - ( + (modBy + Constants.UI.local_variants_per_tile (noise_function tile_inst.location.x tile_inst.location.y tile_inst.crossing_cost ) - % Constants.UI.local_variants_per_tile ) get_omnimods : Type -> Struct.Omnimods.Type diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index ef1ed73..b64b285 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -16,6 +16,8 @@ import Action.Ports import Struct.Flags +import Util.Html + -- Battle ---------------------------------------------------------------------- import Constants.IO @@ -239,7 +241,9 @@ apply_to model query_result = (Result.Err error) -> ( (Struct.Model.invalidate - (Struct.Error.new Struct.Error.Networking (toString error)) + (Struct.Error.new Struct.Error.Networking + (Util.Http.error_to_string error) + ) model ), Cmd.none -- cgit v1.2.3-70-g09d2