Exemplo n.º 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)
Exemplo n.º 2
0
    # TODO make a better way to copy models
    new_ranking = models.Ranking(tournament.name, tournament.date, tournament.location, tid)
    assigned_points_per_match = new_ranking.compute_new_ratings(old_ranking, matches)
    assigned_points_per_best_round = new_ranking.compute_bonus_points(best_rounds)
    assigned_participation_points = new_ranking.add_participation_points(pid_participation_list)

#        print(pid_new_players)
#        for pid in pid_new_players:
#            new_rating = new_ranking[pid].rating
#            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]