Catch the ValueError when an AI asks if an out-of-bounds tile is walkable
This commit is contained in:
parent
635aea5e3b
commit
edbc76d2ff
1 changed files with 4 additions and 1 deletions
|
@ -77,7 +77,10 @@ class HostileEnemy(AI):
|
|||
directions.remove(direction)
|
||||
new_position = self.entity.position + direction
|
||||
overlaps_existing_entity = any(new_position == ent.position for ent in engine.entities)
|
||||
tile_is_walkable = engine.map.tile_is_walkable(new_position)
|
||||
try:
|
||||
tile_is_walkable = engine.map.tile_is_walkable(new_position)
|
||||
except ValueError:
|
||||
tile_is_walkable = False
|
||||
if not overlaps_existing_entity and tile_is_walkable:
|
||||
if engine.map.visible[tuple(self.entity.position)]:
|
||||
log.AI.info('Hero is NOT visible to %s, bumping %s randomly', self.entity, direction)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue