summaryrefslogtreecommitdiff |
diff options
-rw-r--r-- | src/battle/src/Struct/Character.elm | 15 | ||||
-rw-r--r-- | src/battle/src/Struct/CharacterTurn.elm | 4 | ||||
-rw-r--r-- | src/battle/src/Struct/Model.elm | 2 | ||||
-rw-r--r-- | src/battle/src/Struct/TurnResult.elm | 36 | ||||
-rw-r--r-- | src/battle/src/Update/RequestDirection.elm | 6 | ||||
-rw-r--r-- | src/battle/src/Update/SelectTile.elm | 7 | ||||
-rw-r--r-- | src/battle/src/Update/SwitchWeapon.elm | 7 | ||||
-rw-r--r-- | src/battle/src/Update/UndoAction.elm | 28 | ||||
-rw-r--r-- | src/shared/battle-characters/BattleCharacters/Struct/Character.elm | 24 | ||||
-rw-r--r-- | src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm | 8 |
10 files changed, 84 insertions, 53 deletions
diff --git a/src/battle/src/Struct/Character.elm b/src/battle/src/Struct/Character.elm index 868519d..88356f5 100644 --- a/src/battle/src/Struct/Character.elm +++ b/src/battle/src/Struct/Character.elm @@ -11,6 +11,7 @@ module Struct.Character exposing set_current_health, get_location, set_location, + dirty_set_location, is_enabled, is_defeated, is_alive, @@ -28,9 +29,11 @@ import Json.Decode.Pipeline -- Battle ---------------------------------------------------------------------- import Battle.Struct.Omnimods +import Battle.Struct.Statistics -- Battle Characters ----------------------------------------------------------- import BattleCharacters.Struct.Character +import BattleCharacters.Struct.Equipment -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Location @@ -128,6 +131,7 @@ set_location : ( Battle.Struct.Omnimods.Type -> Type -> Type + ) set_location location omnimods char = let previous_max_health = @@ -140,10 +144,16 @@ set_location location omnimods char = {char | location = location, base = - (BattleCharacters.Struct.Character.set_extra_omnimods omnimods) + (BattleCharacters.Struct.Character.set_extra_omnimods + omnimods + char.base + ) } ) +dirty_set_location : BattleMap.Struct.Location.Type -> Type -> Type +dirty_set_location location char = { char | location = location } + get_base_character : Type -> BattleCharacters.Struct.Character.Type get_base_character char = char.base @@ -180,7 +190,6 @@ decoder = (Json.Decode.succeed Unresolved |> (Json.Decode.Pipeline.required "ix" Json.Decode.int) - |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) |> (Json.Decode.Pipeline.required "rnk" @@ -215,7 +224,7 @@ resolve location_omnimod_resolver equipment_resolver ref = ix = ref.ix, rank = ref.rank, location = ref.location, - health = ref.location, + health = ref.health, player_ix = ref.player_ix, enabled = ref.enabled, defeated = ref.defeated, diff --git a/src/battle/src/Struct/CharacterTurn.elm b/src/battle/src/Struct/CharacterTurn.elm index 369b851..825f29a 100644 --- a/src/battle/src/Struct/CharacterTurn.elm +++ b/src/battle/src/Struct/CharacterTurn.elm @@ -121,7 +121,7 @@ lock_path ct = navigator = (Just (Struct.Navigator.lock_path old_nav)) } - (_, _) -> + _ -> ct unlock_path : Type -> Type @@ -134,7 +134,7 @@ unlock_path ct = navigator = (Just (Struct.Navigator.unlock_path old_nav)) } - (_, _) -> + _ -> ct show_attack_range_navigator : Int -> Int -> Type -> Type diff --git a/src/battle/src/Struct/Model.elm b/src/battle/src/Struct/Model.elm index 10224db..86055b2 100644 --- a/src/battle/src/Struct/Model.elm +++ b/src/battle/src/Struct/Model.elm @@ -8,6 +8,8 @@ module Struct.Model exposing add_weapon, add_armor, add_portrait, + add_glyph_board, + add_glyph, add_player, add_tile, invalidate, diff --git a/src/battle/src/Struct/TurnResult.elm b/src/battle/src/Struct/TurnResult.elm index 7599a7f..7325e93 100644 --- a/src/battle/src/Struct/TurnResult.elm +++ b/src/battle/src/Struct/TurnResult.elm @@ -116,10 +116,12 @@ apply_movement_step tile_omnimods movement characters players = ) Nothing -> - (Struct.Character.set_location - (tile_omnimods (Struct.Character.get_location char)) - char - ) + let current_location = (Struct.Character.get_location char) in + (Struct.Character.set_location + current_location + (tile_omnimods current_location) + char + ) ) characters ), @@ -141,16 +143,23 @@ apply_inverse_movement_step tile_omnimods movement characters players = (Util.Array.update_unsafe movement.character_index (\char -> - (Struct.Character.refresh_omnimods - (tile_omnimods) - (Struct.Character.set_location - (List.foldr - (BattleMap.Struct.Location.neighbor) - (movement.destination) - (List.map (BattleMap.Struct.Direction.opposite_of) movement.path) + ( + let + location = + (List.foldr + (BattleMap.Struct.Location.neighbor) + (movement.destination) + (List.map + (BattleMap.Struct.Direction.opposite_of) + movement.path + ) + ) + in + (Struct.Character.set_location + location + (tile_omnimods location) + char ) - char - ) ) ) characters @@ -176,6 +185,7 @@ apply_switched_weapon weapon_switch characters players = (BattleCharacters.Struct.Character.switch_weapons (Struct.Character.get_base_character char) ) + char ) ) characters diff --git a/src/battle/src/Update/RequestDirection.elm b/src/battle/src/Update/RequestDirection.elm index 676b54a..fc7b63b 100644 --- a/src/battle/src/Update/RequestDirection.elm +++ b/src/battle/src/Update/RequestDirection.elm @@ -74,8 +74,10 @@ apply_to : ( ) apply_to model dir = case - (Struct.CharacterTurn.try_getting_navigator model.char_turn) - (Struct.CharacterTurn.try_getting_active_character model.char_turn) + ( + (Struct.CharacterTurn.try_getting_navigator model.char_turn), + (Struct.CharacterTurn.try_getting_active_character model.char_turn) + ) of ((Just navigator), (Just char)) -> ( diff --git a/src/battle/src/Update/SelectTile.elm b/src/battle/src/Update/SelectTile.elm index 11899b5..4eb772a 100644 --- a/src/battle/src/Update/SelectTile.elm +++ b/src/battle/src/Update/SelectTile.elm @@ -92,7 +92,7 @@ go_to_another_tile model char navigator loc_ref = char_turn = (Struct.CharacterTurn.set_navigator new_navigator - (Struct.CharacterTurn.set_active_char + (Struct.CharacterTurn.set_active_character (Struct.Character.set_base_character (BattleCharacters.Struct.Character.set_extra_omnimods (Struct.Model.tile_omnimods_fun @@ -103,9 +103,10 @@ go_to_another_tile model char navigator loc_ref = ) (Struct.Character.get_base_character char) ) + char ) + model.char_turn ) - model.char_turn ), ui = (Struct.UI.set_displayed_tab @@ -151,7 +152,7 @@ go_to_tile model char navigator loc_ref = ) ) then (go_to_current_tile model loc_ref) - else (to_to_another_tile model char navigator loc_ref) + else (go_to_another_tile model char navigator loc_ref) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- diff --git a/src/battle/src/Update/SwitchWeapon.elm b/src/battle/src/Update/SwitchWeapon.elm index 881689d..06d3472 100644 --- a/src/battle/src/Update/SwitchWeapon.elm +++ b/src/battle/src/Update/SwitchWeapon.elm @@ -16,7 +16,12 @@ import Struct.Model -------------------------------------------------------------------------------- make_it_so : Struct.Model.Type -> Struct.Model.Type make_it_so model = - case (Struct.CharacterTurn.try_getting_active_character model.char_turn) of + case + ( + (Struct.CharacterTurn.try_getting_active_character model.char_turn), + (Struct.CharacterTurn.try_getting_navigator model.char_turn) + ) + of ((Just char), (Just nav)) -> let new_base_character = diff --git a/src/battle/src/Update/UndoAction.elm b/src/battle/src/Update/UndoAction.elm index 9d2e710..85fb6c2 100644 --- a/src/battle/src/Update/UndoAction.elm +++ b/src/battle/src/Update/UndoAction.elm @@ -7,6 +7,7 @@ import Array import Battle.Struct.Statistics -- Battle Characters ----------------------------------------------------------- +import BattleCharacters.Struct.Character import BattleCharacters.Struct.Weapon -- Battle Map ------------------------------------------------------------------ @@ -78,23 +79,22 @@ handle_undo_switched_weapons model = Nothing -> model.char_turn (Just char) -> - let - new_char = (Struct.Character.toggle_is_using_primary char) - tile_omnimods = (Struct.Model.tile_omnimods_fun model) - in - (Struct.CharacterTurn.lock_path - tile_omnimods - (Struct.CharacterTurn.unlock_path - tile_omnimods - (Struct.CharacterTurn.set_has_switched_weapons - False - (Struct.CharacterTurn.set_active_character_no_reset - new_char - model.char_turn + (Struct.CharacterTurn.lock_path + (Struct.CharacterTurn.unlock_path + (Struct.CharacterTurn.set_has_switched_weapons + False + (Struct.CharacterTurn.set_active_character_no_reset + (Struct.Character.set_base_character + (BattleCharacters.Struct.Character.switch_weapons + (Struct.Character.get_base_character char) + ) + char ) + model.char_turn ) ) ) + ) handle_undo_chose_target : Struct.Model.Type -> Struct.CharacterTurn.Type handle_undo_chose_target model = @@ -102,9 +102,7 @@ handle_undo_chose_target model = tile_omnimods = (Struct.Model.tile_omnimods_fun model) in (Struct.CharacterTurn.lock_path - (tile_omnimods) (Struct.CharacterTurn.unlock_path - (tile_omnimods) (Struct.CharacterTurn.set_target Nothing model.char_turn) ) ) diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm index 7b34bd4..b91817c 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm @@ -9,7 +9,7 @@ module BattleCharacters.Struct.Character exposing dirty_set_equipment, get_omnimods, set_extra_omnimods, - dirty_set_extra_omnimods + dirty_set_extra_omnimods, get_attributes, get_statistics, get_active_weapon, @@ -22,6 +22,10 @@ module BattleCharacters.Struct.Character exposing ) -- Elm ------------------------------------------------------------------------- +import Json.Decode +import Json.Decode.Pipeline + +import Json.Encode -- Battle ---------------------------------------------------------------------- import Battle.Struct.Omnimods @@ -40,18 +44,18 @@ import BattleCharacters.Struct.GlyphBoard type alias Type = { name : String, - equipment : BattleCharacters.Struct.Equipment, + equipment : BattleCharacters.Struct.Equipment.Type, attributes : Battle.Struct.Attributes.Type, statistics : Battle.Struct.Statistics.Type, is_using_secondary : Bool, omnimods : Battle.Struct.Omnimods.Type, - extra_omnimods : Battle.Struct.Omnimods.Type, + extra_omnimods : Battle.Struct.Omnimods.Type } type alias Unresolved = { name : String, - equipment : BattleCharacters.Struct.Unresolved, + equipment : BattleCharacters.Struct.Equipment.Unresolved, is_using_secondary : Bool } @@ -102,7 +106,7 @@ refresh_omnimods char = -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- get_active_weapon : Type -> BattleCharacters.Struct.Weapon.Type -get_active_weapon char +get_active_weapon char = if (char.is_using_secondary) then (BattleCharacters.Struct.Equipment.get_secondary_weapon char.equipment) else (BattleCharacters.Struct.Equipment.get_primary_weapon char.equipment) @@ -111,7 +115,7 @@ get_inactive_weapon : Type -> BattleCharacters.Struct.Weapon.Type get_inactive_weapon char = if (char.is_using_secondary) then (BattleCharacters.Struct.Equipment.get_primary_weapon char.equipment) - then (BattleCharacters.Struct.Equipment.get_secondary_weapon char.equipment) + else (BattleCharacters.Struct.Equipment.get_secondary_weapon char.equipment) get_name : Type -> String get_name c = c.name @@ -129,13 +133,13 @@ dirty_set_equipment : BattleCharacters.Struct.Equipment.Type -> Type -> Type dirty_set_equipment equipment char = {char | equipment = equipment} get_omnimods : Type -> Battle.Struct.Omnimods.Type -get_omnimods c = c.current_omnimods +get_omnimods char = char.omnimods set_extra_omnimods : Battle.Struct.Omnimods.Type -> Type -> Type -set_extra_omnimods om c = (refresh_omnimods {char | extra_omnimods = om}) +set_extra_omnimods om char = (refresh_omnimods {char | extra_omnimods = om}) dirty_set_extra_omnimods : Battle.Struct.Omnimods.Type -> Type -> Type -dirty_set_extra_omnimods om c = {char | extra_omnimods = om} +dirty_set_extra_omnimods om char = {char | extra_omnimods = om} get_attributes : Type -> Battle.Struct.Attributes.Type get_attributes char = char.attributes @@ -154,7 +158,7 @@ dirty_switch_weapons char = {char | is_using_secondary = (not char.is_using_secondary)} decoder : (Json.Decode.Decoder Unresolved) -decoder : +decoder = (Json.Decode.succeed Unresolved |> (Json.Decode.Pipeline.required "nam" Json.Decode.string) diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm b/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm index 2a3df55..4d0b1fb 100644 --- a/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm +++ b/src/shared/battle-characters/BattleCharacters/Struct/Equipment.elm @@ -15,10 +15,10 @@ module BattleCharacters.Struct.Equipment exposing set_glyph_board, set_glyphs, set_glyph, - ref_decoder, - ref_encoder, + decoder, + encode, resolve, - to_ref + to_unresolved ) -- Elm ------------------------------------------------------------------------- @@ -141,7 +141,7 @@ encode ref = ("ar", (Json.Encode.string ref.armor)), ("pt", (Json.Encode.string ref.portrait)), ("gb", (Json.Encode.string ref.glyph_board)), - ("gl", (Json.Encode.array (Array.map (Json.Encode.string) ref.gl))) + ("gl", (Json.Encode.array (Json.Encode.string) ref.glyphs)) ] ) |