From 090560af836c645f509fd1fa22fd401b0d85f0e4 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 20 Oct 2017 16:36:31 +0200 Subject: Fixes being able to leave the map. No idea how it still worked when the characters where outside the map... --- src/battlemap/src/Battlemap.elm | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/battlemap/src/Battlemap.elm b/src/battlemap/src/Battlemap.elm index a3a0c76..c524576 100644 --- a/src/battlemap/src/Battlemap.elm +++ b/src/battlemap/src/Battlemap.elm @@ -67,20 +67,26 @@ tile_cost_function bmap start_loc char_list loc = then 0 else - case - (Array.get (location_to_index bmap loc) bmap.content) - of - (Just tile) -> - if - (List.any - (\c -> ((Character.get_location c) == loc)) - char_list - ) - then - Constants.Movement.cost_when_occupied_tile - else - (Battlemap.Tile.get_cost tile) - Nothing -> Constants.Movement.cost_when_out_of_bounds + if (has_location bmap loc) + then + case + (Array.get (location_to_index bmap loc) bmap.content) + of + (Just tile) -> + if + (List.any + (\c -> ((Character.get_location c) == loc)) + char_list + ) + then + Constants.Movement.cost_when_occupied_tile + else + (Battlemap.Tile.get_cost tile) + + Nothing -> Constants.Movement.cost_when_out_of_bounds + else + Constants.Movement.cost_when_out_of_bounds + -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2