Linting
This commit is contained in:
@ -194,11 +194,13 @@ class Map:
|
||||
self.add_entity(dictclasses[entisave["type"]](**entisave))
|
||||
|
||||
@staticmethod
|
||||
def neighbourhood(grid, y, x, large=False, oob=False):
|
||||
def neighbourhood(grid: List[List["Tile"]], y: int, x: int,
|
||||
large: bool = False, oob: bool = False) \
|
||||
-> List[List[int]]:
|
||||
"""
|
||||
Returns up to 8 nearby coordinates, in a 3x3 square around the input coordinate if large is
|
||||
set to True, or in a 5-square cross by default. Does not return coordinates if they are out
|
||||
of bounds.
|
||||
Returns up to 8 nearby coordinates, in a 3x3 square around the input
|
||||
coordinate if large is set to True, or in a 5-square cross by default.
|
||||
Does not return coordinates if they are out of bounds.
|
||||
"""
|
||||
height, width = len(grid), len(grid[0])
|
||||
neighbours = []
|
||||
@ -208,8 +210,8 @@ class Map:
|
||||
else:
|
||||
dyxs = [[0, -1], [0, 1], [-1, 0], [1, 0]]
|
||||
for dy, dx in dyxs:
|
||||
if oob or (0 <= y+dy < height and 0 <= x+dx < width):
|
||||
neighbours.append([y+dy, x+dx])
|
||||
if oob or (0 <= y + dy < height and 0 <= x + dx < width):
|
||||
neighbours.append([y + dy, x + dx])
|
||||
return neighbours
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user