diff --git a/minefield.py b/minefield.py index 014c0b8..a649f5a 100644 --- a/minefield.py +++ b/minefield.py @@ -91,19 +91,16 @@ class Minefield: # === MOVEMENT === # # ================ # - # check if sapper's destination is accessible if so then change position of the Agent - # If Agent comes upon a tile with a mine his starting position shall be reestablished + # check if sapper's destination is accessible + # If Agent comes upon a tile with a mine his starting position shall be reestablished def is_valid_move(self, target_row: int, target_column: int): - if 0 <= target_row < const.V_GRID_VER_TILES and \ - 0 <= target_column < const.V_GRID_HOR_TILES: - if self.matrix[target_row][target_column].mine is None: - self.agent.position[0] = target_row - self.agent.position[1] = target_column - else: - self.agent.position[0] = int(self.agent.row) - self.agent.position[1] = int(self.agent.column) - ctypes.windll.user32.MessageBoxW(0, "Znowu się nie udało", "GAME OVER", 1) - # This part of the pop up message is just a temporary solution + if 0 <= target_row < const.V_GRID_VER_TILES \ + and 0 <= target_column < const.V_GRID_HOR_TILES \ + and self.matrix[target_row][target_column] is None: + + return True + + return False # distinguishes new mine's type and creates appropriate object def _create_mine(self, mine_data, row, column):