Return value of Generator.run should be a Map

This commit is contained in:
Charles Peyrat 2021-01-08 03:37:10 +01:00
parent bb3422f7d8
commit 5cbf15bef5
1 changed files with 7 additions and 1 deletions

View File

@ -110,6 +110,12 @@ class Generator:
self.place_room(level, height//2, width//2, 0, 0, starting_room)
self.params["corridor"] = mem
# find a starting position
sy, sx = randint(0, height-1), randint(0, width-1)
while level[sy][sx] != Tile.FLOOR:
sy, sx = randint(0, height-1), randint(0, width-1)
# now we loop until we've tried enough, or we've added enough rooms
tries, rooms_built = 0, 0
while tries < self.params["tries"] and rooms_built < self.params["max_rooms"]:
@ -124,4 +130,4 @@ class Generator:
# post-processing
self.place_walls(level)
return level
return Map(width, height, level, sy, sx)