remove CellInvalidWallError, more refactoring

This commit is contained in:
Dan Anglin 2024-02-14 10:21:15 +00:00
parent 98a7533de8
commit 609ae4fae9
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
2 changed files with 3 additions and 19 deletions

View file

@ -99,12 +99,10 @@ class Cell:
""" """
return self._centre return self._centre
def wall_exists(self, wall: int) -> bool: def wall_exists(self, wall: CellWallLabel) -> bool:
""" """
returns True if a given cell wall exists, or false otherwise. returns True if a given cell wall exists, or false otherwise.
""" """
if wall not in self._walls:
raise errors.CellInvalidWallError(wall)
return self._walls[wall].exists return self._walls[wall].exists
# def break_walls_r(self, i: int, j: int) -> None: # def break_walls_r(self, i: int, j: int) -> None:
@ -121,8 +119,8 @@ class Cell:
if not self._window: if not self._window:
return return
for _, wall in self._walls.items(): for label in CellWallLabel:
wall.draw() self._walls[label].draw()
def draw_move(self, to_cell: 'Cell', undo: bool = False) -> None: def draw_move(self, to_cell: 'Cell', undo: bool = False) -> None:
""" """

View file

@ -1,17 +1,3 @@
class CellInvalidWallError(Exception):
"""
CellInvalidWallError is raised when the program tries to specify a Cell's
Wall that does not exist.
"""
def __init__(self, wall: int, *args):
super().__init__(args)
self.wall = wall
def __str__(self):
return f"Invalid Cell Wall (wall int: {self.wall}) specified."
class CellInvalidError(Exception): class CellInvalidError(Exception):
""" """
CellInvalidError is raised when the program tries to create a Cell whose CellInvalidError is raised when the program tries to create a Cell whose