aboutsummaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'elm/battlemap/src/Battlemap/Navigator.elm')
-rw-r--r-- | elm/battlemap/src/Battlemap/Navigator.elm | 105 |
1 files changed, 78 insertions, 27 deletions
diff --git a/elm/battlemap/src/Battlemap/Navigator.elm b/elm/battlemap/src/Battlemap/Navigator.elm index b040013..9cdfc1f 100644 --- a/elm/battlemap/src/Battlemap/Navigator.elm +++ b/elm/battlemap/src/Battlemap/Navigator.elm @@ -2,43 +2,94 @@ module Battlemap.Navigator exposing ( Type, new, - reset + get_current_location, + get_remaining_points, + get_range_markers, + add_step ) -import Set +import Dict -import Battlemap -import Battlemap.Direction import Battlemap.Location -import Battlemap.Tile +import Battlemap.Navigator.Path +import Battlemap.Navigator.RangeIndicator +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- type alias Type = { - current_location : Battlemap.Location.Type, - visited_locations : (Set.Set Battlemap.Location.Ref), - previous_directions : (List Battlemap.Direction.Type), - remaining_points : Int, - starting_location : Battlemap.Location.Type, - starting_points : Int + starting_location: Battlemap.Location.Type, + movement_dist: Int, + attack_dist: Int, + path: Battlemap.Navigator.Path.Type, + range_indicators: + (Dict.Dict + Battlemap.Location.Ref + Battlemap.Navigator.RangeIndicator.Type + ) } -new : Battlemap.Location.Type -> Int -> Type -new start points = +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +new : ( + Battlemap.Location.Type -> + Int -> + Int -> + (Battlemap.Location.Type -> Bool) -> Type + ) +new start_loc mov_dist atk_dist can_cross_fun = { - current_location = start, - visited_locations = Set.empty, - previous_directions = [], - remaining_points = points, - starting_location = start, - starting_points = points + starting_location = start_loc, + movement_dist = mov_dist, + attack_dist = atk_dist, + path = (Battlemap.Navigator.Path.new start_loc mov_dist), + range_indicators = + (Battlemap.Navigator.RangeIndicator.generate + start_loc + mov_dist + atk_dist + (can_cross_fun) + ) } -reset : Type -> Type -reset nav = - {nav | - current_location = nav.starting_location, - visited_locations = Set.empty, - previous_directions = [], - remaining_points = nav.starting_points - } +get_current_location : Type -> Battlemap.Location.Type +get_current_location navigator = + (Battlemap.Navigator.Path.get_current_location navigator.path) + +get_remaining_points : Type -> Int +get_remaining_points navigator = + (Battlemap.Navigator.Path.get_remaining_points navigator.path) + +get_range_markers : ( + Type -> + (List + (Battlemap.Location.Ref, Battlemap.Navigator.RangeIndicator.Type) + ) + ) +get_range_markers navigator = (Dict.toList navigator.range_indicators) + +add_step : ( + Type -> + Battlemap.Direction.Type -> + (Battlemap.Location.Type -> Bool) -> + (Maybe Type) + ) +add_step navigator dir can_cross = + case + (Battlemap.Navigator.Path.follow_direction + can_cross + (Just navigator.path) + dir + ) + of + (Just path) -> (Just {navigator | path = path} + Nothing -> Nothing |