Implement method room_fits
This commit is contained in:
parent
5cbf15bef5
commit
ddbd0299a0
|
@ -28,6 +28,20 @@ class Generator:
|
|||
def __init__(self, params: dict = DEFAULT_PARAMS):
|
||||
self.params = params
|
||||
|
||||
@staticmethod
|
||||
def room_fits(level, y, x, room, door_y, door_x, dy, dx):
|
||||
if level[y][x] != Tile.EMPTY or level[y-dy][x-dx] != Tile.FLOOR:
|
||||
return False
|
||||
lh, lw = len(level), len(level[0])
|
||||
rh, rw = len(room), len(room[0])
|
||||
for ry in range(rh):
|
||||
for rx in range(rw):
|
||||
if room[y][x] == Tile.FLOOR:
|
||||
ly, lx = ry - door_y, rx - door_x
|
||||
if not(0 <= ly <= rh and 0 <= lx <= rw) or \
|
||||
level[ly][lx] == Tile.FLOOR:
|
||||
return False
|
||||
return True
|
||||
def corr_meta_info(self):
|
||||
if random() < self.params["corridor_chance"]:
|
||||
h_sup = randint(self.params["min_h_corr"], \
|
||||
|
|
Loading…
Reference in New Issue