diff --git a/erynrl/actions/game.py b/erynrl/actions/game.py index e793005..e014c1f 100644 --- a/erynrl/actions/game.py +++ b/erynrl/actions/game.py @@ -71,8 +71,8 @@ class BumpAction(MoveAction): def perform(self, engine: 'Engine') -> ActionResult: new_position = self.actor.position + self.direction - position_is_in_bounds = engine.map.tile_is_in_bounds(new_position) - position_is_walkable = engine.map.tile_is_walkable(new_position) + position_is_in_bounds = engine.map.point_is_in_bounds(new_position) + position_is_walkable = engine.map.point_is_walkable(new_position) for ent in engine.entities: if new_position != ent.position or not ent.blocks_movement: diff --git a/erynrl/ai.py b/erynrl/ai.py index f7a30c1..cca9331 100644 --- a/erynrl/ai.py +++ b/erynrl/ai.py @@ -78,10 +78,10 @@ class HostileEnemy(AI): new_position = self.entity.position + direction overlaps_existing_entity = any(new_position == ent.position for ent in engine.entities) try: - tile_is_walkable = engine.map.tile_is_walkable(new_position) + point_is_walkable = engine.map.point_is_walkable(new_position) except ValueError: - tile_is_walkable = False - if not overlaps_existing_entity and tile_is_walkable: + point_is_walkable = False + if not overlaps_existing_entity and point_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) action = BumpAction(self.entity, direction) diff --git a/erynrl/engine.py b/erynrl/engine.py index b28424a..0bdeca0 100644 --- a/erynrl/engine.py +++ b/erynrl/engine.py @@ -17,13 +17,13 @@ from .events import EngineEventHandler, GameOverEventHandler from .map import Map from .map.generator import RoomsAndCorridorsGenerator from .map.generator.cellular_atomata import CellularAtomataMapGenerator +from .map.generator.corridor import ElbowCorridorGenerator from .map.generator.room import ( BSPRectMethod, CellularAtomatonRoomMethod, OrRoomMethod, RoomGenerator, RectangularRoomMethod) -from .map.generator.corridor import ElbowCorridorGenerator from .messages import MessageLog from .object import Actor, Entity, Hero, Monster diff --git a/erynrl/map/__init__.py b/erynrl/map/__init__.py index 7eb80f2..fb1ae32 100644 --- a/erynrl/map/__init__.py +++ b/erynrl/map/__init__.py @@ -9,7 +9,6 @@ import random from typing import Iterable import numpy as np -import numpy.typing as npt import tcod from ..configuration import Configuration @@ -82,25 +81,25 @@ class Map: self.tiles.shape) if self.tiles[x, y]['walkable']] return random.choice(self.__walkable_points) - def tile_is_in_bounds(self, point: Point) -> bool: + def point_is_in_bounds(self, point: Point) -> bool: '''Return True if the given point is inside the bounds of the map''' return 0 <= point.x < self.size.width and 0 <= point.y < self.size.height - def tile_is_walkable(self, point: Point) -> bool: + def point_is_walkable(self, point: Point) -> bool: '''Return True if the tile at the given point is walkable''' - if not self.tile_is_in_bounds(point): + if not self.point_is_in_bounds(point): raise ValueError(f'Point {point!s} is not in bounds') return self.tiles[point.numpy_index]['walkable'] def point_is_visible(self, point: Point) -> bool: '''Return True if the point is visible to the player''' - if not self.tile_is_in_bounds(point): + if not self.point_is_in_bounds(point): raise ValueError(f'Point {point!s} is not in bounds') return self.visible[point.numpy_index] def point_is_explored(self, point: Point) -> bool: '''Return True if the tile at the given point has been explored by the player''' - if not self.tile_is_in_bounds(point): + if not self.point_is_in_bounds(point): raise ValueError(f'Point {point!s} is not in bounds') return self.explored[point.numpy_index] @@ -109,7 +108,7 @@ class Map: self.highlighted.fill(False) for pt in points: - self.highlighted[pt.x, pt.y] = True + self.highlighted[pt.numpy_index] = True def find_walkable_path_from_point_to_point(self, point_a: Point, point_b: Point) -> Iterable[Point]: '''