def players_menu(): """ Display player's menu :return: none """ players_loaded = scooting_player() if players_loaded == 0: u_choice = choice_menu(PLAYER_0_LOADED_MENU_STRING["string"], PLAYER_0_LOADED_MENU_STRING["cases"], PLAYER_0_LOADED_MENU_STRING["Header"]) else: u_choice = choice_menu(P_MENU_STRING["string"], P_MENU_STRING["cases"], P_MENU_STRING["Header"]) if u_choice == P_MENU_STRING["cases"][0]: if not make_a_player(display_make_a_player()): choice_menu(S_C_PLAYER["string"], S_C_PLAYER["cases"], S_C_PLAYER["Header"]) elif u_choice == "2": u_choice2 = choice_menu(players_loaded["string"], players_loaded["cases"], "Chargement de Joueur") if not make_a_player(loading_player(u_choice2), False): choice_menu(S_C_PLAYER["string"], S_C_PLAYER["cases"], S_C_PLAYER["Header"]) elif u_choice == P_MENU_STRING["cases"][-1]: quit()
def player_menu_2(): """ Display edition menu allow edit player ronk :return: none """ u_choice2 = choice_menu(MOD_PLAYER["string"], MOD_PLAYER["cases"], "Chargement de Joueur") if u_choice2 == "1": players_loaded = scooting_player() u_choice2 = choice_menu(players_loaded["string"], players_loaded["cases"], "Editions des joueurs") display_head_menu("edition") edit_ranking(u_choice2, display("Entrez le nouveau classement : ", "natural")) return 1 else: return 1
def first_menu_action(): """ Display the first menu. choce between quit and make a tournament :return: none """ u_choice = choice_menu(FIRST_MENU["string"], FIRST_MENU["cases"], FIRST_MENU["Header"]) if u_choice == FIRST_MENU["cases"][0]: tournament_menu() else: quit()
def in_round_menu(): """ Main menu. Menu with the different choce you have. :return: none """ if len(current_tournament.rounds) < current_tournament.number_of_round: u_choice = choice_menu(IN_ROUND_MENU["string"], IN_ROUND_MENU["cases"], IN_ROUND_MENU["Header"]) if u_choice == "1": pairing() display_rounding() scoring() saving_tournament(current_tournament) saving_players() in_round_menu() elif u_choice == "2": if player_menu_2() == 1: in_round_menu() elif u_choice == "3": if rapport_menu() == 1: in_round_menu() elif u_choice == "9": quit() else: u_choice = choice_menu(END_ROUND_MENU["string"], END_ROUND_MENU["cases"], END_ROUND_MENU["Header"]) if u_choice == "1": if a_sort_by_ranking_in_tournament() == 1: in_round_menu() elif u_choice == "2": if player_menu_2() == 1: in_round_menu() elif u_choice == "3": rapport_menu() in_round_menu() elif u_choice == "9": quit()
def tournament_menu(): """ Display tournament menu :return: none """ tournament_loaded = scooting_tournament() if tournament_loaded == 0: u_choice = choice_menu(TOURNAMENT_0_LOADED_MENU_STRING["string"], TOURNAMENT_0_LOADED_MENU_STRING["cases"], TOURNAMENT_0_LOADED_MENU_STRING["Header"]) else: u_choice = choice_menu(T_MENU_STRING["string"], T_MENU_STRING["cases"], T_MENU_STRING["Header"]) if u_choice == T_MENU_STRING["cases"][0]: make_a_tournament(display_make_a_tournament()) elif u_choice == "2": u_choice2 = choice_menu(tournament_loaded["string"], tournament_loaded["cases"], "Chargement de Tournois") make_a_tournament(loading_tournament(u_choice2), False) elif u_choice == u_choice == T_MENU_STRING["cases"][-1]: pass
def a_sort_by_ranking_in_tournament(): """ display player sorted by ranking :return: none """ i = 1 string = "" for player in sort_players(): try: string +=\ f"{i}. {player.lastname}" \ f" {player.firstname}" \ f" {player.tournament_point[current_tournament.identity]}" \ f" points\n" except KeyError: string +=\ f"{i}. {player.lastname}" \ f" {player.firstname}" \ f" \n" i += 1 string += "\n tapez sur (1) pour continuez" choice_menu(string, ["1"], "Classement") return 1
def rapport_menu(): """ display the rapport menu :return: none """ u_choice = choice_menu(RAPPORT_MENU_STRING["string"], RAPPORT_MENU_STRING["cases"], RAPPORT_MENU_STRING["Header"]) if u_choice == "1": u_choice = choice_menu(RAPPORT_ACTOR["string"], RAPPORT_ACTOR["cases"], RAPPORT_ACTOR["Header"]) if u_choice == "1": display_head_menu("Ordre alphabétique") a_sort_by__alpha() input("\ntapez sur un touche pour continuez") return 1 else: display_head_menu("Par classement") a_sort_by_ranking() input("\ntapez sur un touche pour continuez") return 1 elif u_choice == "2": u_choice = choice_menu(RAPPORT_ACTOR_IN["string"], RAPPORT_ACTOR_IN["cases"], RAPPORT_ACTOR_IN["Header"]) if u_choice == "1": display_head_menu("Ordre alphabétique") a_sort_by_alpha_in_tournament() input("\ntapez sur un touche pour continuez") return 1 else: display_head_menu("Par classement") a_sort_by_ranking_in_tournament() input("\ntapez sur un touche pour continuez") return 1 elif u_choice == "3": display_head_menu("liste de tous les tournois") i = 1 for tournament in get_db("tournament"): print(f"{i}. {tournament['name']}") i += 1 input("\ntapez sur un touche pour continuez") return 1 elif u_choice == "4": display_head_menu("liste de tous les tours du tournois'") for c_round in current_tournament.rounds: print( f"{c_round.name} - debut: {c_round.starting_date} - fin: {c_round.ending_date}" ) input("\ntapez sur un touche pour continuez") return 1 elif u_choice == "5": display_head_menu("liste de tous les matchs du tounois") for c_round in current_tournament.rounds: print(f"\n{c_round.name}") for match in c_round.matches: player1 = "" player2 = "" winner = "" for player in players: if player.identity == match[0][0]: player1 = f"{player.lastname} {player.firstname}" if player.identity == match[1][0]: player2 = f"{player.lastname} {player.firstname}" if match[0][1] == 1: winner = player1 if match[1][1] == 1: winner = player2 if match[0][1] == 0.5: winner = "Nulle" print(f"{player1} vs {player2} victoire : {winner}") input("\ntapez sur un touche pour continuez") return 1 elif u_choice == "6": return 1 elif u_choice == "9": quit()