diff options
Diffstat (limited to 'imago/gameLogic/gameState.py')
-rw-r--r-- | imago/gameLogic/gameState.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/imago/gameLogic/gameState.py b/imago/gameLogic/gameState.py index 72b91b4..c577713 100644 --- a/imago/gameLogic/gameState.py +++ b/imago/gameLogic/gameState.py @@ -40,32 +40,31 @@ class GameState: def playMoveForPlayer(self, row, col, player): """Execute a move on the board for the given player.""" + # Check a last move already exists + if self.lastMove is None: + raise RuntimeError("Last move of the GameState is None.") + prevBoards = self.lastMove.getThisAndPrevBoards() playable, message = self.lastMove.board.isPlayable(row, col, player, prevBoards) if playable: self._addMove(player, row, col) return True - print("Invalid Move! %s" % message) + raise Exception("Invalid Move. %s" % message) return False def playPass(self): """Passes the turn for the player who should make a move.""" - self.lastMove.addPass() + self.lastMove = self.lastMove.addPass() def passForPlayer(self, player): """Passes the turn for the given player.""" - self.lastMove.addPassForPlayer(player) + self.lastMove = self.lastMove.addPassForPlayer(player) def undo(self): """Sets the move before the last move as the new last move.""" self.lastMove = self.lastMove.previousMove def _addMove(self, player, row, col): - - # Check a last move already exists - if self.lastMove is None: - raise RuntimeError("Last move of the GameState is None.") - # Add and return the new move self.lastMove = self.lastMove.addMoveForPlayer(row, col, player) return self.lastMove |