def _create_new_game(self): """Create a new game, on demand or on start""" GameManager.new_game() self.game = GameManager.instance() self.selected = None self.redraw.emit() if self.players_select[UICommons.BLACK_STR].isChecked(): self._computers_move()
def test_apply_move(self): #an empty game game = GameManager.instance() game._board = Board.create_empty_board(game) game.board()[0] = Bishop(Common.white, game) self.assertEqual(game.board()[0].get_type(), Bishop) self.assertIsNone(game.board()[Common.board_size * 2 - 1]) game.board()[0].apply_move((0, Common.board_size * 2 - 1, None)) self.assertEqual(game.board()[Common.board_size * 2 - 1].get_type(), Bishop) self.assertIsNone(game.board()[0])
def __new__(cls, name, bases, attrs): game_class = type.__new__(cls, name, bases, attrs) GameManager.set_managed_class(game_class) return game_class
def apply_move(move): """Common move of all figures, but rooks and pawns, which may have special behavior.""" game = GameManager.instance() source, destination, _ = move game.board()[destination] = game.board()[source] game.board()[source] = None