예제 #1
0
    for name in tournament.get_players_names():
        if players.get_pid(name) is None:
            association = input("Enter the association of %s:\n" % name)
            city = input("Enter the city of %s:\n" % name)
            # Assign a pid for the new given player and add it to the list
            players.add_new_player(name, association, city)
            print(players[players.get_pid(name)])

        pid = players.get_pid(name)

        if ranking.get_entry(pid) is None:
            initial_rating = int(input("Enter the initial rating points for %s:\n" % name))
            ranking.add_new_entry(pid, initial_rating)
            print(ranking[pid])

        # Log current tournament as the last played tournament
        players[pid].last_tournament = tid

# Saving complete list of players, including new ones
utils.save_sheet_workbook(
    xlsx_file,
    cfg["sheetname"]["players"],
    [cfg["labels"][key] for key in ["PID", "Player", "Association", "City", "Last Tournament"]],
    sorted(players.to_list(), key=lambda l: l[1]),
    True,
)

# Saving initial rankings for all known players
utils.save_ranking_sheet(xlsx_file, cfg["sheetname"]["initial_ranking"], ranking, players, True)
예제 #2
0
#            old_rating = old_ranking[pid].rating
#            update_dic[pid] = new_rating - old_rating
#            print(pid, old_rating, new_rating, new_rating - old_rating, update_dic[pid])

    # Saving new ranking
    utils.save_ranking_sheet(rankings_xlsx, tournament_sheetname.replace(cfg["sheetname"]["tournaments_key"],
                                                                         cfg["sheetname"]["rankings_key"]),
                             new_ranking, players, True)

    # Saving points assigned in each match
    points_log_to_save = [[players[winner_pid].name, players[loser_pid].name, winner_points, loser_points]
                          for winner_pid, loser_pid, winner_points, loser_points in assigned_points_per_match]

    utils.save_sheet_workbook(log_xlsx,
                              tournament_sheetname.replace(cfg["sheetname"]["tournaments_key"],
                                                           cfg["sheetname"]["rating_details_key"]),
                              [cfg["labels"][key] for key in ["Winner", "Loser", "Winner Points", "Loser Points"]],
                              points_log_to_save, True)

    # Saving points assigned per best round reached and for participation
    points_log_to_save = [[players[pid].name, points, best_round, category] for pid, points, best_round, category
                          in assigned_points_per_best_round]
    participation_points_log_to_save = [[players[pid].name, points, cfg["labels"]["Participation Points"], ""]
                                        for pid, points in assigned_participation_points]

    utils.save_sheet_workbook(log_xlsx,
                              tournament_sheetname.replace(cfg["sheetname"]["tournaments_key"],
                                                           cfg["sheetname"]["bonus_details_key"]),
                              [cfg["labels"][key] for key in ["Player", "Bonus Points", "Best Round", "Category"]],
                              points_log_to_save + participation_points_log_to_save, True)