Exemplo n.º 1
0
    def execute(move_piece_command):
        board = move_piece_command.get_board()
        origin_coordinates = move_piece_command.get_origin_coordinates()
        destination_coordinates = move_piece_command.get_destination_coordinates()
        color = move_piece_command.get_color()

        ValidateMoveService.execute(ValidateMoveCommand(board, origin_coordinates, destination_coordinates, color))

        board.get_grid()[destination_coordinates[0]][destination_coordinates[1]].set_piece(
            board.get_grid()[origin_coordinates[0]][origin_coordinates[1]].get_piece()
        )
        board.get_grid()[origin_coordinates[0]][origin_coordinates[1]].remove_piece()
Exemplo n.º 2
0
 def test_execute_path_obstructed_error(self):
     with self.assertRaises(PieceMovementPathObstructedException):
         ValidateMoveService.execute(
             ValidateMoveCommand(self.board, (1, 7), (3, 5), Color.WHITE))
Exemplo n.º 3
0
 def test_execute_square_not_reachable_error(self):
     with self.assertRaises(InvalidMovementForPieceException):
         ValidateMoveService.execute(
             ValidateMoveCommand(self.board, (2, 0), (3, 1), Color.WHITE))
Exemplo n.º 4
0
 def test_execute_square_occupied_friend_error(self):
     with self.assertRaises(DestinationSquareOccupiedException):
         ValidateMoveService.execute(
             ValidateMoveCommand(self.board, (0, 0), (2, 0), Color.WHITE))
Exemplo n.º 5
0
 def test_execute_square_occupied_enemy_error(self):
     with self.assertRaises(OriginSquareContainsEnemyPieceException):
         ValidateMoveService.execute(
             ValidateMoveCommand(self.board, (6, 0), (5, 0), Color.WHITE))
Exemplo n.º 6
0
 def test_execute_empty_square_error(self):
     with self.assertRaises(OriginSquareEmptyException):
         ValidateMoveService.execute(
             ValidateMoveCommand(self.board, (1, 0), (3, 0), Color.WHITE))
Exemplo n.º 7
0
 def test_execute_valid(self):
     ValidateMoveService.execute(
         ValidateMoveCommand(self.board, (0, 0), (1, 0), Color.WHITE))