From 20911dd1bc9f35e97f0a7bebcd5dce70747d6cf1 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 16 Mar 2018 13:50:09 +0100 Subject: Fixes navigator attack range when moving 1 step. --- src/battlemap/src/Struct/Battlemap.elm | 47 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/src/battlemap/src/Struct/Battlemap.elm b/src/battlemap/src/Struct/Battlemap.elm index bc002ef..5a4c88c 100644 --- a/src/battlemap/src/Struct/Battlemap.elm +++ b/src/battlemap/src/Struct/Battlemap.elm @@ -91,31 +91,28 @@ get_movement_cost_function : ( Int ) get_movement_cost_function bmap start_loc char_list loc = - if - ( - (Struct.Location.get_ref start_loc) - == - (Struct.Location.get_ref loc) - ) + if (has_location bmap 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 + case + (Array.get (location_to_index bmap loc) bmap.content) + of + (Just tile) -> + if + (List.any + ( + \c -> + ( + ((Struct.Character.get_location c) == loc) + && (loc /= start_loc) + ) ) - then - Constants.Movement.cost_when_occupied_tile - else - (Struct.Tile.get_cost tile) + 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 + Nothing -> Constants.Movement.cost_when_out_of_bounds + else + Constants.Movement.cost_when_out_of_bounds -- cgit v1.2.3-70-g09d2