| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/battlemap/src/ElmModule/Update.elm | 18 | ||||
| -rw-r--r-- | src/battlemap/src/Struct/Battlemap.elm | 74 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SelectCharacter.elm | 22 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SendLoadBattlemapRequest.elm | 4 | ||||
| -rw-r--r-- | src/battlemap/src/Update/SwitchTeam.elm | 4 | 
5 files changed, 67 insertions, 55 deletions
| diff --git a/src/battlemap/src/ElmModule/Update.elm b/src/battlemap/src/ElmModule/Update.elm index 947b232..b8ae924 100644 --- a/src/battlemap/src/ElmModule/Update.elm +++ b/src/battlemap/src/ElmModule/Update.elm @@ -8,11 +8,15 @@ import Struct.Error  import Struct.UI  import Struct.Model -import Update.RequestDirection -import Update.SelectTile -import Update.SelectCharacter +import Update.ChangeScale  import Update.EndTurn  import Update.HandleServerReply +import Update.RequestDirection +import Update.SelectCharacter +import Update.SelectTab +import Update.SelectTile +import Update.SendLoadBattlemapRequest +import Update.SwitchTeam  import Send.LoadBattlemap @@ -42,14 +46,14 @@ update event model =           (Update.ChangeScale.apply_to new_model mod)        (Struct.Event.TabSelected tab) -> -         (Update.SelectTab.apply_to new_model mod) +         (Update.SelectTab.apply_to new_model tab)        Struct.Event.DebugTeamSwitchRequest ->           (Update.SwitchTeam.apply_to new_model) -      (Event.DebugLoadBattlemapRequest) -> +      (Struct.Event.DebugLoadBattlemapRequest) ->           (Update.SendLoadBattlemapRequest.apply_to new_model) -      (Event.ServerReplied result) -> -         (Model.HandleServerReply.apply_to model result) +      (Struct.Event.ServerReplied result) -> +         (Update.HandleServerReply.apply_to model result) diff --git a/src/battlemap/src/Struct/Battlemap.elm b/src/battlemap/src/Struct/Battlemap.elm index 93ea71d..c30dfd2 100644 --- a/src/battlemap/src/Struct/Battlemap.elm +++ b/src/battlemap/src/Struct/Battlemap.elm @@ -6,6 +6,7 @@ module Struct.Battlemap exposing        get_width,        get_height,        get_tiles, +      get_movement_cost_function,        try_getting_tile_at     ) @@ -47,42 +48,6 @@ has_location bmap loc =        && (loc.y < bmap.height)     ) -tile_cost_function : ( -      Type -> -      Struct.Location.Type -> -      (List Struct.Character.Type) -> -      Struct.Location.Type -> -      Int -   ) -tile_cost_function bmap start_loc char_list loc = -   if -      ( -         (Struct.Location.get_ref start_loc) -         == -         (Struct.Location.get_ref loc) -      ) -   then -      0 -   else -      if (has_location bmap loc) -      then -         case -            (Array.get (location_to_index bmap loc) bmap.content) -         of -            (Just tile) -> -               if -                  (List.any -                     (\c -> ((Struct.Character.get_location c) == loc)) -                     char_list -                  ) -               then -                  Constants.Movement.cost_when_occupied_tile -               else -                  (Struct.Tile.get_cost tile) - -            Nothing -> Constants.Movement.cost_when_out_of_bounds -      else -         Constants.Movement.cost_when_out_of_bounds  --------------------------------------------------------------------------------  -- EXPORTED -------------------------------------------------------------------- @@ -119,3 +84,40 @@ try_getting_tile_at : (     )  try_getting_tile_at bmap loc =     (Array.get (location_to_index bmap loc) bmap.content) + +get_movement_cost_function : ( +      Type -> +      Struct.Location.Type -> +      (List Struct.Character.Type) -> +      Struct.Location.Type -> +      Int +   ) +get_movement_cost_function bmap start_loc char_list loc = +   if +      ( +         (Struct.Location.get_ref start_loc) +         == +         (Struct.Location.get_ref loc) +      ) +   then +      0 +   else +      if (has_location bmap loc) +      then +         case +            (Array.get (location_to_index bmap loc) bmap.content) +         of +            (Just tile) -> +               if +                  (List.any +                     (\c -> ((Struct.Character.get_location c) == loc)) +                     char_list +                  ) +               then +                  Constants.Movement.cost_when_occupied_tile +               else +                  (Struct.Tile.get_cost tile) + +            Nothing -> Constants.Movement.cost_when_out_of_bounds +      else +         Constants.Movement.cost_when_out_of_bounds diff --git a/src/battlemap/src/Update/SelectCharacter.elm b/src/battlemap/src/Update/SelectCharacter.elm index bddd12f..42c53d6 100644 --- a/src/battlemap/src/Update/SelectCharacter.elm +++ b/src/battlemap/src/Update/SelectCharacter.elm @@ -12,6 +12,7 @@ import Struct.Error  import Struct.Event  import Struct.UI  import Struct.Model +import Struct.Navigator  import Update.RequestDirection @@ -28,8 +29,9 @@ attack_character : (  attack_character model main_char_id target_char_id target_char =     {model |        char_turn = -         (Struct.CharacterTurn.add_target target_char_id model.char_turn), -      ui = (Struct.UI.set_previous_action model.ui Nothing) +         (Struct.CharacterTurn.add_target model.char_turn target_char_id), +      ui = +         (Struct.UI.set_previous_action model.ui Nothing)     }  select_character : ( @@ -47,15 +49,17 @@ select_character model target_char_id target_char =              (Struct.CharacterTurn.set_navigator                 (Struct.CharacterTurn.set_controlled_character                    model.char_turn -                  target_char_id +                  target_char                 ) -               (Struct.Character.get_location target_char) -               (Struct.Character.get_movement_points target_char) -               (Struct.Character.get_attack_range target_char) -               (Struct.Battlemap.get_movement_cost_function -                  (Dict.values model.characters) +               (Struct.Navigator.new                    (Struct.Character.get_location target_char) -                  model.battlemap +                  (Struct.Character.get_movement_points target_char) +                  (Struct.Character.get_attack_range target_char) +                  (Struct.Battlemap.get_movement_cost_function +                     model.battlemap +                     (Struct.Character.get_location target_char) +                     (Dict.values model.characters) +                  )                 )              ),           ui = (Struct.UI.set_previous_action model.ui Nothing) diff --git a/src/battlemap/src/Update/SendLoadBattlemapRequest.elm b/src/battlemap/src/Update/SendLoadBattlemapRequest.elm index 2ed248d..cd6db1f 100644 --- a/src/battlemap/src/Update/SendLoadBattlemapRequest.elm +++ b/src/battlemap/src/Update/SendLoadBattlemapRequest.elm @@ -2,8 +2,10 @@ module Update.SendLoadBattlemapRequest exposing (apply_to)  -- Elm -------------------------------------------------------------------------  -- Battlemap ------------------------------------------------------------------- -import Struct.Model +import Send.LoadBattlemap +  import Struct.Event +import Struct.Model  import Struct.UI  -------------------------------------------------------------------------------- diff --git a/src/battlemap/src/Update/SwitchTeam.elm b/src/battlemap/src/Update/SwitchTeam.elm index f85dd87..09319f3 100644 --- a/src/battlemap/src/Update/SwitchTeam.elm +++ b/src/battlemap/src/Update/SwitchTeam.elm @@ -20,7 +20,7 @@ apply_to model =     if (model.controlled_team == 0)     then        ( -         (Model.reset +         (Struct.Model.reset              {model |                 controlled_team = 1,                 player_id = "1" @@ -31,7 +31,7 @@ apply_to model =        )     else        ( -         (Model.reset +         (Struct.Model.reset              {model |                 controlled_team = 0,                 player_id = "0" | 


