changed move validation return type to Boolean
This commit is contained in:
parent
9e429dff9f
commit
925350569d
21
minefield.py
21
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):
|
||||
|
Loading…
Reference in New Issue
Block a user