From 2805c647010cbcca126ebf162fcbdd691fc72488 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Wed, 18 Oct 2017 13:48:58 +0200 Subject: Correcting whatever the compiler tells me is wrong. --- elm/battlemap/src/Battlemap/Navigator.elm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'elm/battlemap/src/Battlemap/Navigator.elm') diff --git a/elm/battlemap/src/Battlemap/Navigator.elm b/elm/battlemap/src/Battlemap/Navigator.elm index 2c2734d..ac394b5 100644 --- a/elm/battlemap/src/Battlemap/Navigator.elm +++ b/elm/battlemap/src/Battlemap/Navigator.elm @@ -5,7 +5,8 @@ module Battlemap.Navigator exposing get_current_location, get_remaining_points, get_range_markers, - add_step + try_adding_step, + try_getting_path_to ) import Dict @@ -78,14 +79,14 @@ get_range_markers : ( ) get_range_markers navigator = (Dict.toList navigator.range_indicators) -add_step : ( +try_adding_step : ( Type -> Battlemap.Direction.Type -> (Battlemap.Location.Type -> Bool) -> (Battlemap.Location.Type -> Int) -> (Maybe Type) ) -add_step navigator dir can_cross cost_fun = +try_adding_step navigator dir can_cross cost_fun = case (Battlemap.Navigator.Path.try_following_direction can_cross @@ -96,3 +97,14 @@ add_step navigator dir can_cross cost_fun = 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 -- cgit v1.2.3-70-g09d2