From 6fbc757f1e2b46e7dc4da95400dc26b1fbdeb81e Mon Sep 17 00:00:00 2001 From: Charles Peyrat Date: Fri, 8 Jan 2021 04:43:10 +0100 Subject: [PATCH] Implement method place_walls --- squirrelbattle/mapgeneration/broguelike.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/squirrelbattle/mapgeneration/broguelike.py b/squirrelbattle/mapgeneration/broguelike.py index 1a6f70c..6101ceb 100644 --- a/squirrelbattle/mapgeneration/broguelike.py +++ b/squirrelbattle/mapgeneration/broguelike.py @@ -52,6 +52,17 @@ class Generator: for rx in range(rw): if room[y][x] == Tile.FLOOR: level[y-door_y][y-door_x] = Tile.FLOOR + + @staticmethod + def place_walls(level): + h, w = len(level), len(level[0]) + for y in range(h): + for x in range(w): + if level[y][x] == Tile.FLOOR: + for dy, dx in Map.neighbourhood(level, y, x): + if level[y+dy][x+dx] == Tile.EMPTY: + level[y+dy][x+dx] = Tile.FLOOR + def corr_meta_info(self): if random() < self.params["corridor_chance"]: h_sup = randint(self.params["min_h_corr"], \