def enter_results(): tournament = Tournament({}) tournament.restore() for match in tournament.tours[tournament.active_tour].matchs: print(f"Round {tournament.active_tour}") print(f"Joueur (Joueur 1): {match.player1.surname} " f"{match.player1.forename}") print(f"Contre (Joueur 2): {match.player2.surname} " f"{match.player2.forename}") match_score = input("1. Joueur 1 gagnant\n" "2. Joueur 2 gagnant\n" "3. Match Null\n") match_score = convert_to_integer(match_score) if not match_score or match_score < 1 or match_score > 3: print("Le score dois être un entier compris entre 1 et 3.") return if match_score == 1: match.score1 = 1 match.score2 = 0 if match_score == 2: match.score1 = 0 match.score2 = 1 if match_score == 3: match.score1 = 0.5 match.score2 = 0.5 tournament.save()
def tournament_score(): tournament = Tournament({}) tournament.restore() for _ in tournament.players: print( f"Joueur: {_.surname} {_.forename} - " f"{tournament.score_player(_)} point(s)." )
def active_tournament_info(): tournament = Tournament({}) tournament.restore() print("Tournois actif:\n" "---------------\n" f"Nom: {tournament.name}\n" f"Date: {tournament.date}\n" f"Tour actif: {tournament.active_tour + 1}")
def sorted_by_rank(): tournament = Tournament({}) tournament.restore() print("\nAffichage des joueurs par rang:\n" "-------------------------------\n") ranked_players = tournament.list_players_by_rank() rank = 0 for _ in ranked_players: rank += 1 print(f"{rank} - {_.rank} {_.surname}" f" {_.forename}")
def sorted_by_names(): tournament = Tournament({}) tournament.restore() print("\nAffichage des joueurs par ordre alphabétique:\n" "---------------------------------------------\n") ranked_players = tournament.list_players_by_names() rank = 0 for _ in ranked_players: rank += 1 print(f"{rank} - {_.surname} {_.forename}")
def update_players_ranks(): tournament = Tournament({}) tournament.restore() for _ in tournament.players: print(f"Joueur: {_.surname} {_.forename} - {_.rank} (actuel)") new_rank = input("Nouveau classement: ") new_rank = convert_to_integer(new_rank) if not new_rank: print("Le nouveau classement dois être un entier, on passe au " "suivant.") continue else: _.rank = new_rank tournament.save()
def tournament_backup(): tournament = Tournament({}) tournament.restore() tournament.backup_new()
def next_tour(): tournament = Tournament({}) tournament.restore() tournament.new_tour()