From a3c380b2813c9928a2ee600c276295c7803e9e66 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 15 Mar 2019 23:10:22 +0100 Subject: Got everything to compile again. --- .../battle-map/BattleMap/Struct/Location.elm | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/shared/battle-map') diff --git a/src/shared/battle-map/BattleMap/Struct/Location.elm b/src/shared/battle-map/BattleMap/Struct/Location.elm index 3443150..da3b8ef 100644 --- a/src/shared/battle-map/BattleMap/Struct/Location.elm +++ b/src/shared/battle-map/BattleMap/Struct/Location.elm @@ -27,6 +27,13 @@ type alias Ref = (Int, Int) -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +new : Int -> Int -> Type +new x y = + { + x = x, + y = y + } + neighbor : BattleMap.Struct.Direction.Type -> Type -> Type neighbor dir loc = case dir of @@ -68,3 +75,27 @@ encode loc = ( "y", (Json.Encode.int loc.y) ) ] ) + +neighbors : Type -> (List Type) +neighbors loc = + [ + {loc | x = (loc.x + 1)}, + {loc | x = (loc.x - 1)}, + {loc | y = (loc.y - 1)}, + {loc | y = (loc.y + 1)} + ] + +get_full_neighborhood : Type -> (List Type) +get_full_neighborhood loc = + [ + {loc | x = (loc.x - 1), y = (loc.y - 1)}, + {loc | y = (loc.y - 1)}, + {loc | x = (loc.x + 1), y = (loc.y - 1)}, + {loc | x = (loc.x - 1)}, + {loc | x = (loc.x + 1)}, + {loc | x = (loc.x - 1), y = (loc.y + 1)}, + {loc | y = (loc.y + 1)}, + {loc | x = (loc.x + 1), y = (loc.y + 1)} + ] + + -- cgit v1.2.3-70-g09d2