def test_json(self): player_1 = chessapi.Player(chessapi.WHITE) player_2 = chessapi.Player(chessapi.BLACK) first_game = chessapi.Game(player_1, player_2) first_game.move((1, 0), (2, 2), player_1) json_representation = first_game.get_json_from_board() second_game = chessapi.Game(player_1, player_2) second_game.build_board_from_json(json_representation) second_game.colour_for_next_turn = chessapi.BLACK self.assertEqual(first_game.piece_at_position((2, 2)), second_game.piece_at_position((2, 2)))
def test_initialisation(self): """ Makes sure that basic initialisation of the pieces does not raise any errors. """ chessapi.Pawn( chessapi.DiscreteVector(0, 0), chessapi.WHITE, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK))) chessapi.Rook( chessapi.DiscreteVector(0, 0), chessapi.BLACK, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK))) chessapi.Knight( chessapi.DiscreteVector(0, 0), chessapi.WHITE, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK))) chessapi.Bishop( chessapi.DiscreteVector(0, 0), chessapi.BLACK, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK))) chessapi.Queen( chessapi.DiscreteVector(0, 0), chessapi.WHITE, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK))) chessapi.King( chessapi.DiscreteVector(0, 0), chessapi.BLACK, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK)))
def test_player_colour_validation(self): player_1 = chessapi.Player(chessapi.WHITE) player_2 = chessapi.Player(chessapi.BLACK) with self.assertRaises(chessapi.IncorrectPlayerColourError): game = chessapi.Game(player_2, player_1)
def setUp(self): self.piece = chessapi.Piece( chessapi.DiscreteVector(0, 0), chessapi.WHITE, chessapi.Game(chessapi.Player(chessapi.WHITE), chessapi.Player(chessapi.BLACK)))
def setUp(self): self.player_1 = chessapi.Player(chessapi.WHITE) self.player_2 = chessapi.Player(chessapi.BLACK) self.game = chessapi.Game(self.player_1, self.player_2)