Exemplo n.º 1
0
def player_stats(p, stage):
    reply = None
    player_name = PLAYERS.get(p.lower(), p).lower()
    if stage == 0:  # show stats for all stages
        for player in STATS:
            if player['name'].lower() == player_name:
                reply = PLAYER_RESPONSE.format(
                    player['name'], player['role'].title(),
                    TEAMS.get(player['team'], player['team']),
                    player['eliminations_avg_per_10m'],
                    player['deaths_avg_per_10m'],
                    player['hero_damage_avg_per_10m'],
                    player['healing_avg_per_10m'],
                    player['ultimates_earned_avg_per_10m'],
                    player['final_blows_avg_per_10m'],
                    player['time_played_total'] / 60 / 60) + FOOTER
                break
    else:
        for player in STAGE_STATS[stage - 1]:
            if player['name'].lower() == player_name:
                reply = PLAYER_RESPONSE.format(
                    player['name'] + ' in Stage ' + str(stage),
                    player['role'].title(),
                    TEAMS.get(player['team'], player['team']),
                    player['eliminations_avg_per_10m'],
                    player['deaths_avg_per_10m'],
                    player['hero_damage_avg_per_10m'],
                    player['healing_avg_per_10m'],
                    player['ultimates_earned_avg_per_10m'],
                    player['final_blows_avg_per_10m'],
                    player['time_played_total'] / 60 / 60) + FOOTER
                break

    return reply
Exemplo n.º 2
0
def init():
    teams = TEAMS.copy()
    players = clean_data(PLAYERS)
    balanced_teams = balance_teams(teams, players)
    intro_msg()
    while True:
        team_index = get_user_selected_team(balanced_teams)
        display_team_stats(balanced_teams[team_index])
Exemplo n.º 3
0
def player_comparison(p1, p2, stage):
    reply = None
    player1, player2 = None, None
    player1_name = PLAYERS.get(p1.lower(), p1).lower()
    player2_name = PLAYERS.get(p2.lower(), p2).lower()
    if stage == 0:
        for player in STATS:
            if player['name'].lower() == player1_name:
                player1_name = player['name']
                player1 = player
            if player['name'].lower() == player2_name:
                player2_name = player['name']
                player2 = player
    else:
        for player in STAGE_STATS[stage - 1]:
            if player['name'].lower() == player1_name:
                player1_name = player['name']
                player1 = player
            if player['name'].lower() == player2_name:
                player2_name = player['name']
                player2 = player
    if player1 is not None and player2 is not None:
        reply = COMPARISON_RESPONSE.format(
            player1_name, player2_name + ' in Stage ' + str(stage),
            player1_name, player1['role'].title(),
            TEAMS.get(player1['team'],
                      player1['team']), player2_name, player2['role'].title(),
            TEAMS.get(player2['team'], player2['team']), player1_name,
            player2_name, player1['eliminations_avg_per_10m'],
            player2['eliminations_avg_per_10m'], player1['deaths_avg_per_10m'],
            player2['deaths_avg_per_10m'], player1['hero_damage_avg_per_10m'],
            player2['hero_damage_avg_per_10m'], player1['healing_avg_per_10m'],
            player2['healing_avg_per_10m'],
            player1['ultimates_earned_avg_per_10m'],
            player2['ultimates_earned_avg_per_10m'],
            player1['final_blows_avg_per_10m'],
            player2['final_blows_avg_per_10m'], player1['time_played_total'] /
            60 / 60, player2['time_played_total'] / 60 / 60) + FOOTER
    return reply
Exemplo n.º 4
0
def root():
    spi1 = spi2 = score1 = score2 = None
    team1 = request.args.get('team1', None)
    team2 = request.args.get('team2', None)
    league = request.args.get('league', None)

    if team1 and team2 and league:
        spi1 = TEAMS[team1]
        spi2 = TEAMS[team2]

        matches = [{
            'date': datetime.now().strftime("%Y-%m-%d"),
            'league': league,
            'team1': team1,
            'team2': team2,
            'spi1': spi1,
            'spi2': spi2
        }, {
            'date': datetime.now().strftime("%Y-%m-%d"),
            'league': league,
            'team1': team2,
            'team2': team1,
            'spi1': spi2,
            'spi2': spi1
        }]
        predictions = requests.post(
            "{server_url}/api/v2/deployments/{deployment_id}/predictions".
            format(server_url=DEPLOYMENT_SERVER_URL,
                   deployment_id=DEPLOYMENT_ID),
            headers=PREDICTION_HEADERS,
            data=json.dumps(matches),
        )

        print(predictions.json())

        score1 = float(predictions.json()['data'][0]['prediction'])
        score2 = float(predictions.json()['data'][1]['prediction'])

    return render_template('index.html',
                           teams=TEAMS.keys(),
                           leagues=LEAGUES,
                           team1=team1,
                           team2=team2,
                           league=league,
                           score1=normalize_score(score1),
                           score2=normalize_score(score2))
Exemplo n.º 5
0
                   for item in team_players]  # [42, 40, 45, ...]

    while counter >= 1:
        for team in final_teams:
            tallest_loc = all_heights.index(max(all_heights))  # returns 3
            all_heights.pop(tallest_loc)
            team["players"].append(team_players.pop(tallest_loc))
        counter -= 1
    return final_teams

    # teams: Panthers, Bandits and Warriors.
    # max(height) popped from the list of players and then appended to team that did draft. .pop eliminated it from player pool


if __name__ == "__main__":
    my_team_names = TEAMS.copy()
    my_players = PLAYERS.copy()

    my_team_names, my_players = clean_data(my_team_names, my_players)
    my_teams = balance_teams(my_team_names, my_players)

    print("Basketball Team Statistics Tool\n\n---- Menu ----")

    while True:
        choice1 = input(
            "Please Select From the Following Menus:\n1) Display Team Stats\n2) Quit\nChoice>  "
        )
        if choice1 == "1":
            print(my_teams)
            # TODO display team stats
        elif choice1 == "2":
Exemplo n.º 6
0
def team_selection():
    for team in TEAMS:
        indx = TEAMS.index(team) + 1
        print(f"\n{indx}) {team}")
    return input("\nPlease select one of the above .. > ")