Esempio n. 1
0
def get_person_captain_for_gameweek(
        manager: FantasyPremierLeagueManager,
        gameweek: Union[int, str]) -> Union[None, list]:
    captain_played = False
    vice_captain_played = False
    is_triple_captain = False
    person_picks = manager.get_picks_for_gw(gameweek)
    if not person_picks:
        return
    for player in person_picks["picks"]:
        if player["is_captain"] and player["multiplier"] not in [0, 1]:
            if player["multiplier"] == 3:
                is_triple_captain = True
            captain_played = True
            return [
                PremierLeaguePlayer(player["element"]), captain_played,
                vice_captain_played, is_triple_captain
            ]
        if player["is_vice_captain"] and player["multiplier"] not in [0, 1]:
            if player["multiplier"] == 3:
                is_triple_captain = True
            vice_captain_played = True
            return [
                PremierLeaguePlayer(player["element"]), captain_played,
                vice_captain_played, is_triple_captain
            ]
    return [None, captain_played, vice_captain_played, is_triple_captain]
Esempio n. 2
0
def replace_all_player_ids_with_players_in_stats(stat: dict):
    if not stat["a"] and not stat["h"]:
        return
    for element in stat["a"]:
        if "element" in element:
            element["element"] = PremierLeaguePlayer(element["element"])
    for element in stat["h"]:
        if "element" in element:
            element["element"] = PremierLeaguePlayer(element["element"])
    return stat
Esempio n. 3
0
def replace_player_id_with_player_object(text):
    if text:
        if type(text) == dict:
            if "element" in text:
                text["element"] = PremierLeaguePlayer(text["element"])
        elif type(text) == list:
            for dictionary in text:
                if "element" in dictionary:
                    dictionary["element"] = PremierLeaguePlayer(
                        dictionary["element"])
        else:
            raise TypeError(
                f"Parameter with type {type(text)} is not supported for this function"
            )
    return text
Esempio n. 4
0
def get_all_used_players_per_manager():
    result = dict()
    for manager in config['managers']:
        player_list = list()
        players = get_all_used_players(
            FantasyPremierLeagueManager(config['managers'][manager]), 1, 38)
        for player in players:
            player_list.append(PremierLeaguePlayer(player).web_name)
        result[manager] = {'players': player_list, 'total': len(player_list)}
    return result
Esempio n. 5
0
        players = get_all_used_players(
            FantasyPremierLeagueManager(config['managers'][manager]), 1, 38)
        for player in players:
            player_list.append(PremierLeaguePlayer(player).web_name)
        result[manager] = {'players': player_list, 'total': len(player_list)}
    return result


def update_all_files():
    data.fetch_all_latest_info()


if __name__ == '__main__':
    # update_all_files()
    erwin = FantasyPremierLeagueManager(config["managers"]["erwin"])
    niels = FantasyPremierLeagueManager(config['managers']['niels'])
    bale = PremierLeaguePlayer(543)
    team1 = Team(14)
    team2 = Team(20)
    schuppebekske = League(435851)
    een_fixture = Fixture(200)
    manchester_united = Team(team_short_name="MUN")
    mun_mci = get_fixture(manchester_united, Team(team_short_name="MCI"))

    # print(mun_mci.away_team)
    # print(een_fixture.yellow_cards)
    # print(get_captaincy_points_per_manager(36, 36))
    # print(get_extra_captaincy_points_between_gws(niels, 1, 36))

    print(get_all_used_players_per_manager())