summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/Location.elm | 43 | ||||
-rw-r--r-- | src/shared/battle-map/BattleMap/Struct/Marker.elm | 5 |
2 files changed, 47 insertions, 1 deletions
diff --git a/src/shared/battle-map/BattleMap/Struct/Location.elm b/src/shared/battle-map/BattleMap/Struct/Location.elm index da3b8ef..6b07e90 100644 --- a/src/shared/battle-map/BattleMap/Struct/Location.elm +++ b/src/shared/battle-map/BattleMap/Struct/Location.elm @@ -6,6 +6,8 @@ import Json.Decode.Pipeline import Json.Encode +import Set + -- Battle Map ------------------------------------------------------------------ import BattleMap.Struct.Direction @@ -98,4 +100,43 @@ get_full_neighborhood loc = {loc | x = (loc.x + 1), y = (loc.y + 1)} ] - +add_neighborhood_to_set : ( + Int -> + Int -> + Int -> + Type -> + (Set.Set Ref) -> + (Set.Set Ref) + ) +add_neighborhood_to_set map_width map_height tdist loc set = + (List.foldl + (\height_mod current_width_result -> + let + abs_width_mod = (abs (tdist - height_mod)) + current_height = (loc.y + height_mod) + in + if ((current_height < 0) || (current_height >= map_height)) + then current_width_result + else + (List.foldl + (\width_mod current_result -> + let new_location_x = (loc.x + width_mod) in + if + ( + (new_location_x < 0) + || (new_location_x >= map_width) + ) + then current_result + else + (Set.insert + (new_location_x, current_height) + current_result + ) + ) + current_width_result + (List.range (-abs_width_mod) abs_width_mod) + ) + ) + set + (List.range (-tdist) tdist) + ) diff --git a/src/shared/battle-map/BattleMap/Struct/Marker.elm b/src/shared/battle-map/BattleMap/Struct/Marker.elm index 21a1731..53204cb 100644 --- a/src/shared/battle-map/BattleMap/Struct/Marker.elm +++ b/src/shared/battle-map/BattleMap/Struct/Marker.elm @@ -1,9 +1,11 @@ module BattleMap.Struct.Marker exposing ( Type, + DataType, new, get_locations, set_locations, + get_data, is_in_locations, decoder, encode @@ -84,6 +86,9 @@ get_locations marker = marker.locations set_locations : (Set.Set BattleMap.Struct.Location.Ref) -> Type -> Type set_locations locations marker = {marker | locations = locations} +get_data : Type -> DataType +get_data marker = marker.data + is_in_locations : BattleMap.Struct.Location.Ref -> Type -> Bool is_in_locations loc_ref marker = (Set.member loc_ref marker.locations) |