fpl/models/user.py
def _set_captain(lineup, captain, captain_type, player_ids):
    """Sets the given captain's captain_type to True.

    :param lineup: List of players.
    :type lineup: list
    :param captain: ID of the captain.
    :type captain: int or str
    :param captain_type: The captain type: 'is_captain' or 'is_vice_captain'.
    :type captain_type: string
    :param player_ids: List of the team's players' IDs.
    :type player_ids: list
    """
    if captain and captain not in player_ids:
        raise ValueError(
            "Cannot (vice) captain player who isn't in user's team.")

    current_captain = next(player for player in lineup if player[captain_type])
    chosen_captain = next(player for player in lineup
                          if player["element"] == captain)

    # If the chosen captain is already a (vice) captain, then give his previous
    # role to the current (vice) captain.
    if chosen_captain[is_c] or chosen_captain[is_vc]:
        current_captain[is_c], chosen_captain[is_c] = (
            chosen_captain[is_c], current_captain[is_c])
        current_captain[is_vc], chosen_captain[is_vc] = (
            chosen_captain[is_vc], current_captain[is_vc])

    for player in lineup:
        player[captain_type] = False

        if player["element"] == captain:
            player[captain_type] = True
Sets the given captain's captain_type to True.

    :param lineup: List of players.
    :type lineup: list
    :param captain: ID of the captain.
    :type captain: int or str
    :param captain_type: The captain type: 'is_captain' or 'is_vice_captain'.
    :type captain_type: string
    :param player_ids: List of the team's players' IDs.
    :type player_ids: list
    
Sets the given captain's captain_type to True.
Sets the given captain ' s captain_type to True .
def _set_captain(lineup, captain, captain_type, player_ids):
    if captain and captain not in player_ids:
        raise ValueError(
            "Cannot (vice) captain player who isn't in user's team.")
    current_captain = next(player for player in lineup if player[captain_type])
    chosen_captain = next(player for player in lineup
                          if player["element"] == captain)
    if chosen_captain[is_c] or chosen_captain[is_vc]:
        current_captain[is_c], chosen_captain[is_c] = (
            chosen_captain[is_c], current_captain[is_c])
        current_captain[is_vc], chosen_captain[is_vc] = (
            chosen_captain[is_vc], current_captain[is_vc])
    for player in lineup:
        player[captain_type] = False
        if player["element"] == captain:
            player[captain_type] = True
def _set_captain ( lineup , captain , captain_type , player_ids ) : if captain and captain not in player_ids : raise ValueError ( "Cannot (vice) captain player who isn't in user's team." ) current_captain = next ( player for player in lineup if player [ captain_type ] ) chosen_captain = next ( player for player in lineup if player [ "element" ] == captain ) if chosen_captain [ is_c ] or chosen_captain [ is_vc ] : current_captain [ is_c ] , chosen_captain [ is_c ] = ( chosen_captain [ is_c ] , current_captain [ is_c ] ) current_captain [ is_vc ] , chosen_captain [ is_vc ] = ( chosen_captain [ is_vc ] , current_captain [ is_vc ] ) for player in lineup : player [ captain_type ] = False if player [ "element" ] == captain : player [ captain_type ] = True
Sets the given captain's captain_type to True.
Sets the given captain ' s captain_type to True .
"""Sets the given captain's captain_type to True.

    :param lineup: List of players.
    :type lineup: list
    :param captain: ID of the captain.
    :type captain: int or str
    :param captain_type: The captain type: 'is_captain' or 'is_vice_captain'.
    :type captain_type: string
    :param player_ids: List of the team's players' IDs.
    :type player_ids: list
    """ # If the chosen captain is already a (vice) captain, then give his previous # role to the current (vice) captain.
lineup
List of players.
List of players .
captain
ID of the captain.
ID of the captain .
captain_type
The captain type: 'is_captain' or 'is_vice_captain'.
The captain type : ' is_captain ' or ' is_vice_captain ' .
player_ids
List of the team's players' IDs.
List of the team ' s players ' IDs .