Navigate through different maps while climbing ladders
This commit is contained in:
@ -140,12 +140,15 @@ class Map:
|
||||
Put randomly {count} entities on the map, where it is available.
|
||||
"""
|
||||
for ignored in range(count):
|
||||
y, x = 0, 0
|
||||
while True:
|
||||
y, x = randint(0, self.height - 1), randint(0, self.width - 1)
|
||||
tile = self.tiles[y][x]
|
||||
if tile.can_walk():
|
||||
break
|
||||
try:
|
||||
tile = self.tiles[y][x]
|
||||
except Exception as e:
|
||||
raise Exception(y, x, len(self.tiles))
|
||||
else:
|
||||
if tile.can_walk():
|
||||
break
|
||||
entity = choice(Entity.get_all_entity_classes())()
|
||||
entity.move(y, x)
|
||||
self.add_entity(entity)
|
||||
|
Reference in New Issue
Block a user