From d362bdc949179c1d6afe68feb9bf44eeb0199cd4 Mon Sep 17 00:00:00 2001 From: Charles Peyrat Date: Fri, 8 Jan 2021 06:58:02 +0100 Subject: [PATCH] Fix place_room and add missing argument --- squirrelbattle/mapgeneration/broguelike.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/squirrelbattle/mapgeneration/broguelike.py b/squirrelbattle/mapgeneration/broguelike.py index d6da979..40529e5 100644 --- a/squirrelbattle/mapgeneration/broguelike.py +++ b/squirrelbattle/mapgeneration/broguelike.py @@ -45,14 +45,14 @@ class Generator: return True @staticmethod - def place_room(level, y, x, door_y, door_x, room): + def place_room(level, y, x, room, door_y, door_x): rh, rw = len(room), len(room[0]) # maybe place Tile.DOOR here ? - level[door_y][door_x] = Tile.FLOOR + level[y][x] = Tile.FLOOR for ry in range(rh): for rx in range(rw): if room[ry][rx] == Tile.FLOOR: - level[y-door_y+ry][y-door_x+rx] = Tile.FLOOR + level[y-door_y+ry][x-door_x+rx] = Tile.FLOOR @staticmethod def place_walls(level): @@ -146,9 +146,9 @@ class Generator: # the starting room must have no corridor mem, self.params["corridor_chance"] = self.params["corridor_chance"], 0 starting_room, _, _, _, _ = self.create_random_room() - self.place_room(level, height//2, width//2, 0, 0, starting_room) + self.place_room(level, height//2, width//2, starting_room, 0, 0) self.params["corridor_chance"] = mem - + # find a starting position sy, sx = randint(0, height-1), randint(0, width-1) while level[sy][sx] != Tile.FLOOR: @@ -159,13 +159,13 @@ class Generator: while tries < self.params["tries"] and rooms_built < self.params["max_rooms"]: room, door_y, door_x, dy, dx = self.create_random_room() - positions = [i for i in range()] + positions = [i for i in range(height * width)] shuffle(positions) for pos in positions: y, x = pos // width, pos % width if self.room_fits(level, y, x, room, door_y, door_x, dy, dx): - self.place_room(level, y, x, door_y, door_x, room) - + self.place_room(level, y, x, room, door_y, door_x) + # post-processing self.place_walls(level)