summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2017-10-19 13:30:40 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2017-10-19 13:30:40 +0200 |
commit | e008855086d124f0de14eacc858ecb57d23e371c (patch) | |
tree | e3fe94dcf2966d17ac970b4b9cbbf6998c1f34a6 /elm/battlemap/src/Battlemap/Navigator.elm | |
parent | ab299e08cee6ee9b2b122ce87b9bdab3b0dd637c (diff) |
Starting a more modular approach for the website.
Diffstat (limited to 'elm/battlemap/src/Battlemap/Navigator.elm')
-rw-r--r-- | elm/battlemap/src/Battlemap/Navigator.elm | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/elm/battlemap/src/Battlemap/Navigator.elm b/elm/battlemap/src/Battlemap/Navigator.elm deleted file mode 100644 index 6687b18..0000000 --- a/elm/battlemap/src/Battlemap/Navigator.elm +++ /dev/null @@ -1,141 +0,0 @@ -module Battlemap.Navigator exposing - ( - Type, - Summary, - new, - get_current_location, - get_remaining_points, - get_range_markers, - get_summary, - try_adding_step, - try_getting_path_to - ) - -import Dict - -import Battlemap.Location -import Battlemap.Direction -import Battlemap.Marker - -import Battlemap.Navigator.Path -import Battlemap.Navigator.RangeIndicator - --------------------------------------------------------------------------------- --- TYPES ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -type alias Type = - { - 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 - ) - } - -type alias Summary = - { - starting_location: Battlemap.Location.Type, - path: (List Battlemap.Direction.Type), - markers: (List (Battlemap.Location.Ref, Battlemap.Marker.Type)) - } --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- - -new : ( - Battlemap.Location.Type -> - Int -> - Int -> - (Battlemap.Location.Type -> Bool) -> Type - ) -new start_loc mov_dist atk_dist can_cross_fun = - { - 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) - ) - } - -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) - -get_summary : Type -> Summary -get_summary navigator = - { - starting_location = navigator.starting_location, - path = (Battlemap.Navigator.Path.get_summary navigator.path), - markers = - (List.map - (\(loc, range_indicator) -> - ( - loc, - (Battlemap.Navigator.RangeIndicator.get_marker - range_indicator - ) - ) - ) - (Dict.toList - navigator.range_indicators - ) - ) - } - -try_adding_step : ( - Type -> - Battlemap.Direction.Type -> - (Battlemap.Location.Type -> Bool) -> - (Battlemap.Location.Type -> Int) -> - (Maybe Type) - ) -try_adding_step navigator dir can_cross cost_fun = - case - (Battlemap.Navigator.Path.try_following_direction - can_cross - cost_fun - (Just navigator.path) - dir - ) - of - (Just path) -> (Just {navigator | path = path}) - Nothing -> Nothing - -try_getting_path_to : ( - Type -> - Battlemap.Location.Ref -> - (Maybe (List Battlemap.Direction.Type)) - ) -try_getting_path_to navigator loc_ref = - case (Dict.get loc_ref navigator.range_indicators) of - (Just target) -> - (Just (Battlemap.Navigator.RangeIndicator.get_path target)) - Nothing -> Nothing - |