From 764a36d571bd071ee754678274be54ff5ab40b36 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 25 Nov 2019 11:34:56 +0100 Subject: ... --- src/battle/src/Struct/Battle.elm | 24 ++++++++++------------ src/battle/src/Struct/TurnResultAnimator.elm | 10 +++++++-- src/battle/src/Update/HandleServerReply.elm | 8 +++++++- src/roster-editor/src/Struct/Inventory.elm | 2 +- .../BattleCharacters/Struct/DataSet.elm | 24 +++++++++++----------- .../BattleCharacters/Struct/Portrait.elm | 8 ++++---- .../BattleCharacters/Struct/Skill.elm | 8 ++++---- src/shared/battle-map/BattleMap/Struct/DataSet.elm | 4 ++-- src/shared/battle-map/BattleMap/Struct/Map.elm | 14 ++++++------- src/shared/battle-map/BattleMap/Struct/Tile.elm | 12 +++++++++++ 10 files changed, 67 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/battle/src/Struct/Battle.elm b/src/battle/src/Struct/Battle.elm index 1798786..ae6e3fe 100644 --- a/src/battle/src/Struct/Battle.elm +++ b/src/battle/src/Struct/Battle.elm @@ -24,9 +24,7 @@ module Struct.Battle exposing get_id, - get_own_player_index, - - tile_omnimods_fun + get_own_player_index ) -- Elm ------------------------------------------------------------------------- @@ -39,10 +37,17 @@ import Set -- Battle ---------------------------------------------------------------------- import Battle.Struct.Omnimods +-- Elm ------------------------------------------------------------------------- +import Array + +-- Shared ---------------------------------------------------------------------- +import Struct.Flags + -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Location import BattleMap.Struct.Map import BattleMap.Struct.Marker +import BattleMap.Struct.DataSet -- Local Module ---------------------------------------------------------------- import Struct.Character @@ -121,13 +126,6 @@ regenerate_attack_of_opportunity_markers char_ix battle = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -tile_omnimods_fun : ( - BattleMap.Struct.DataSet.Type -> - (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) - ) -tile_omnimods_fun dataset battle = - (\loc -> (BattleMap.Struct.Map.get_omnimods_at loc dataset battle.map)) - new : Type new = { @@ -180,10 +178,10 @@ set_characters chars battle = {battle | characters = chars} add_player : Struct.Flags.Type -> Struct.Player.Type -> Type -> Type add_player flags pl battle = {battle | - players = (Array.push pl battle.players) + players = (Array.push pl battle.players), own_player_ix = - if (Struct.Player.get_id == (Struct.Flags.get_player_id flags)) - then (Array.size battle.players) + if ((Struct.Player.get_id pl) == (Struct.Flags.get_user_id flags)) + then (Array.length battle.players) else battle.own_player_ix } diff --git a/src/battle/src/Struct/TurnResultAnimator.elm b/src/battle/src/Struct/TurnResultAnimator.elm index 49acdb8..2a1220f 100644 --- a/src/battle/src/Struct/TurnResultAnimator.elm +++ b/src/battle/src/Struct/TurnResultAnimator.elm @@ -10,9 +10,14 @@ module Struct.TurnResultAnimator exposing ) -- Elm ------------------------------------------------------------------------- +import Array import Set +-- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.DataSet + -- Local Module ---------------------------------------------------------------- +import Struct.Battle import Struct.TurnResult -------------------------------------------------------------------------------- @@ -148,8 +153,9 @@ move_animator_to_next_step maybe_animator = apply_animator_step : ( BattleMap.Struct.DataSet.Type -> - Battle.Struct.Type -> - Battle.Struct.Type + Type -> + Struct.Battle.Type -> + Struct.Battle.Type ) apply_animator_step dataset animator battle = case (Struct.TurnResultAnimator.get_current_animation animator) of diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm index 969358e..1ab919e 100644 --- a/src/battle/src/Update/HandleServerReply.elm +++ b/src/battle/src/Update/HandleServerReply.elm @@ -230,7 +230,13 @@ add_character unresolved_char current_state = battle = (Struct.Battle.add_character (Struct.Character.resolve - (Struct.Model.tile_omnimods_fun model) + (\loc -> + (BattleMap.Struct.Map.tile_omnimods_fun + loc + model.map_dataset + (Struct.Battle.get_map model.battle) + ) + ) model.characters_dataset unresolved_char ) diff --git a/src/roster-editor/src/Struct/Inventory.elm b/src/roster-editor/src/Struct/Inventory.elm index 85ae5b5..8b31aec 100644 --- a/src/roster-editor/src/Struct/Inventory.elm +++ b/src/roster-editor/src/Struct/Inventory.elm @@ -105,7 +105,7 @@ allows equipment inv = ) && (List.all - (e -> (has_glyph e inv)) + (\e -> (has_glyph e inv)) (Array.toList (BattleCharacters.Struct.Equipment.get_glyphs equipment)) ) && diff --git a/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm b/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm index 4e3050a..3e938a2 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/DataSet.elm @@ -75,23 +75,23 @@ type alias Type = new : Type new = { - weapons = (Dict.new), - armors = (Dict.new), - glyphs = (Dict.new), - glyph_boards = (Dict.new), - portraits = (Dict.new), - skills = (Dict.new) + weapons = (Dict.empty), + armors = (Dict.empty), + glyphs = (Dict.empty), + glyph_boards = (Dict.empty), + portraits = (Dict.empty), + skills = (Dict.empty) } is_ready : Type -> Bool is_ready data_set = ( - (data_set.portraits /= (Dict.empty)) - && (data_set.weapons /= (Dict.empty)) - && (data_set.armors /= (Dict.empty)) - && (data_set.glyph_boards /= (Dict.empty)) - && (data_set.glyphs /= (Dict.empty)) - && (data_set.skills /= (Dict.empty)) + (not (Dict.isEmpty data_set.portraits)) + && (not (Dict.isEmpty data_set.weapons)) + && (not (Dict.isEmpty data_set.armors)) + && (not (Dict.isEmpty data_set.glyph_boards)) + && (not (Dict.isEmpty data_set.glyphs)) + && (not (Dict.isEmpty data_set.skills)) ) ---- Accessors ----------------------------------------------------------------- diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm index 8fe92c0..66fd764 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Portrait.elm @@ -3,7 +3,7 @@ module BattleCharacters.Struct.Portrait exposing Type, Ref, find, - default, + none, get_id, get_name, get_body_id, @@ -41,10 +41,10 @@ find : (Dict.Dict Ref Type) -> Ref -> Type find dict ref = case (Dict.get ref dict) of (Just e) -> e - Nothing -> default + Nothing -> none -default : Type -default = +none : Type +none = { id = "cat", name = "Black Cat", diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Skill.elm b/src/shared/battle-characters/BattleCharacters/Struct/Skill.elm index 709c17f..cc0dcae 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Skill.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Skill.elm @@ -3,7 +3,7 @@ module BattleCharacters.Struct.Skill exposing Type, Ref, find, - default, + none, get_id, get_name, get_cost, @@ -54,10 +54,10 @@ find : (Dict.Dict Ref Type) -> Ref -> Type find dict ref = case (Dict.get ref dict) of (Just e) -> e - Nothing -> default + Nothing -> none -default : Type -default = +none : Type +none = { id = "", name = "Skill Not Found", diff --git a/src/shared/battle-map/BattleMap/Struct/DataSet.elm b/src/shared/battle-map/BattleMap/Struct/DataSet.elm index f292443..d81daaf 100644 --- a/src/shared/battle-map/BattleMap/Struct/DataSet.elm +++ b/src/shared/battle-map/BattleMap/Struct/DataSet.elm @@ -31,13 +31,13 @@ type alias Type = new : Type new = { - tiles = (Dict.new) + tiles = (Dict.empty) } is_ready : Type -> Bool is_ready data_set = ( - (data_set.tiles /= (Dict.empty)) + (not (Dict.isEmpty data_set.tiles)) ) ---- Accessors ----------------------------------------------------------------- diff --git a/src/shared/battle-map/BattleMap/Struct/Map.elm b/src/shared/battle-map/BattleMap/Struct/Map.elm index d2c950f..73a1cfe 100644 --- a/src/shared/battle-map/BattleMap/Struct/Map.elm +++ b/src/shared/battle-map/BattleMap/Struct/Map.elm @@ -34,6 +34,7 @@ import Util.Array import Battle.Struct.Omnimods -- Battle Map ------------------------------------------------------------------ +import BattleMap.Struct.DataSet import BattleMap.Struct.Location import BattleMap.Struct.Marker import BattleMap.Struct.Tile @@ -183,22 +184,19 @@ solve_tiles tiles map = get_omnimods_at : ( BattleMap.Struct.Location.Type -> - (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type) -> + BattleMap.Struct.DataSet.Type -> Type -> Battle.Struct.Omnimods.Type ) -get_omnimods_at loc tiles_solver map = +get_omnimods_at loc dataset map = case (try_getting_tile_at loc map) of Nothing -> (Battle.Struct.Omnimods.none) (Just tile_inst) -> - case - (Dict.get + (BattleMap.Struct.Tile.get_omnimods + (BattleMap.Struct.DataSet.get_tile (BattleMap.Struct.TileInstance.get_class_id tile_inst) - tiles_solver ) - of - Nothing -> (Battle.Struct.Omnimods.none) - (Just tile) -> (BattleMap.Struct.Tile.get_omnimods tile) + ) decoder : (Json.Decode.Decoder Type) decoder = diff --git a/src/shared/battle-map/BattleMap/Struct/Tile.elm b/src/shared/battle-map/BattleMap/Struct/Tile.elm index 9145b44..53ec2e1 100644 --- a/src/shared/battle-map/BattleMap/Struct/Tile.elm +++ b/src/shared/battle-map/BattleMap/Struct/Tile.elm @@ -9,6 +9,7 @@ module BattleMap.Struct.Tile exposing get_cost, get_omnimods, get_family, + none, decoder ) @@ -75,3 +76,14 @@ decoder = |> (Json.Decode.Pipeline.required "de" Json.Decode.int) |> (Json.Decode.Pipeline.required "omni" Battle.Struct.Omnimods.decoder) ) + +none : Type +none = + { + id = "-1", + name = "Not Found", + crossing_cost = 999, + family = "-1", + depth = 0, + omnimods = (Battle.Struct.Omnimods.none) + } -- cgit v1.2.3-70-g09d2