def find_opponent_square(self, board):
    '\n        Retrieve the index of the square that contains the enemy piece to be captured.\n        '
    path_indexes = get_indexes_between(self.start_index, self.end_index)
    own_color = board.owner[self.start_index]
    own_path_squares = [index for index in path_indexes if (board.owner[index] == own_color)]
    opponent_path_squares = [index for index in path_indexes if (board.owner[index] and (board.owner[index] != own_color))]
    if (len(own_path_squares) > 0):
        msg = 'Cannot capture when own pieces are in the way: {0}'
        raise InvalidMoveException(msg.format(', '.join((str(index) for index in own_path_squares))))
    if (len(opponent_path_squares) != 1):
        msg = 'Cannot capture: must have exactly one opponent piece along the way'
        raise InvalidMoveException(msg)
    if (not board.owner[self.start_index]):
        msg = 'Cannot move from an empty square ({0})'.format(self.start_index)
        raise InvalidMoveException(msg)
    if board.owner[self.end_index]:
        msg = 'Cannot move to a non-empty square ({0})'.format(self.end_index)
        raise InvalidMoveException(msg)
    return opponent_path_squares[0]
Retrieve the index of the square that contains the enemy piece to be captured.
def find_opponent_square(self, board):
    '\n        \n        '
    path_indexes = get_indexes_between(self.start_index, self.end_index)
    own_color = board.owner[self.start_index]
    own_path_squares = [index for index in path_indexes if (board.owner[index] == own_color)]
    opponent_path_squares = [index for index in path_indexes if (board.owner[index] and (board.owner[index] != own_color))]
    if (len(own_path_squares) > 0):
        msg = 'Cannot capture when own pieces are in the way: {0}'
        raise InvalidMoveException(msg.format(', '.join((str(index) for index in own_path_squares))))
    if (len(opponent_path_squares) != 1):
        msg = 'Cannot capture: must have exactly one opponent piece along the way'
        raise InvalidMoveException(msg)
    if (not board.owner[self.start_index]):
        msg = 'Cannot move from an empty square ({0})'.format(self.start_index)
        raise InvalidMoveException(msg)
    if board.owner[self.end_index]:
        msg = 'Cannot move to a non-empty square ({0})'.format(self.end_index)
        raise InvalidMoveException(msg)
    return opponent_path_squares[0]