Example #1
0
 def new_player():
     """
     Create a new player.
     """
     id_player = input("Give an unique ID for the new player : ")
     PlayerManager().create_player(id_player)
     Tournament.load_from_db()
Example #2
0
 def set_round():
     """
     Set the winners of a round.
     """
     id_tournament = input("Give ID of the tournament : ")
     Report.show_all_rounds(id_tournament)
     id_round = Tournament.get(id_tournament).rounds[-1].id_round
     round_done = False
     for match in Round.get(id_round).matches:
         if (match.player_a_score
                 and match.player_b_score) != match.match_in_progress:
             round_done = True
             break
     if not round_done:
         RoundManager().set_results(id_round)
         RoundManager().round_done(id_round)
         if len(Tournament.get(id_tournament).rounds) == Tournament.get(
                 id_tournament).number_rounds:
             Tournament.get(id_tournament).set_tournament_finished()
     elif round_done and Tournament.get(id_tournament).tournament_open:
         print(
             f"The round {id_round} is already set, you have to create another round."
         )
     else:
         print(
             f"The tournament {id_tournament} is already set and clear. You have to create another tournament."
         )
     Tournament.load_from_db()
Example #3
0
    def new_round():
        """
        Create a new round for a tournament.
        """
        id_tournament = input("Give ID of the tournament : ")
        last_round = Tournament.get(id_tournament).rounds[-1].id_round
        last_round_done = True

        if Tournament.get(id_tournament).tournament_open:
            for match in Round.get(last_round).matches:
                if (match.player_a_score
                        or match.player_b_score) == match.match_in_progress:
                    last_round_done = False
                    break
            if last_round_done:
                next_round = int(last_round.split(":")[-1]) + 1
                next_round = f"{id_tournament}:{next_round}"
                RoundManager().create_round(next_round)
            else:
                print(
                    f"The round {last_round} is not finished yet, you can't create the next round."
                )
        else:
            print(
                f"The tournament {id_tournament} is already finished. You cannot create another round."
            )
        Tournament.load_from_db()
Example #4
0
 def set_player():
     """
     Edit the elo of a player
     """
     id_player = input("Give ID of the player : ")
     elo = int(input(f"Give the modified elo for {id_player} : "))
     PlayerManager.edit_elo(id_player, elo)
     Tournament.load_from_db()
Example #5
0
 def new_tournament():
     """
     Create a new tournament.
     """
     id_tournament = input("Give ID of tournament : ")
     if TournamentManager().create_tournament(id_tournament):
         TournamentManager().add_players(id_tournament)
     RoundManager().create_round(f"{id_tournament}:1")
     Tournament.load_from_db()
Example #6
0
 def close_app():
     """
     Close the application.
     """
     Tournament.load_from_db()
     sys.exit()
Example #7
0
 def load():
     """
     Load data from data_base.json
     Needed to get data from previous sessions.
     """
     Tournament.load_from_db()