Пример #1
0
 def __init__(self):
     """
     The attribute menu is a instance of Menu, the option are added in __call__.
     The attribute view handles the display of the menu.
     """
     self.menu = Menu()
     self.view = MenuView(self.menu)
Пример #2
0
class ActorsRank:
    """ Handles the modification of a player's ranking. """
    def __init__(self, next_menu=ActorsMenu()):
        self.menu = Menu()
        self.view = MenuView(self.menu)
        self.next_menu = next_menu

    def __call__(self):
        actor_id = input_actor_id()
        database = DataBaseHandler()
        actor = {}
        if not database.import_actor(
                actor_id) and actor_id not in Actors.actors:
            view_no_actor_id()
        else:
            if actor_id in Actors.actors:
                actor = Actors.actors[actor_id]
            elif database.import_actor(actor_id):
                actor = database.import_actor(actor_id)
            view_validation_new_actor(actor)
            new_rank = input_actor_new_rank()
            actor.rank = new_rank
            Actors.actors[actor.actor_id] = actor
            view_validation_new_actor(actor)

        self.menu.add("auto", "Modifier le classement d'un autre joueur",
                      ActorsRank(self.next_menu))
        self.menu.add("auto", "Retour", self.next_menu)

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #3
0
class ActorsMenu:
    """ Handles the menu of players settings. """
    def __init__(self):
        """
        The attribute menu is a instance of Menu, the option are added in __call__.
        The attribute view handles the display of the menu.
        """
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        """ Calls the display of the menu's introduction.
        The menu is created and the get_user_choice method
        asks for the user choice.
        """
        view_actors_menu()
        self.menu.add("auto", "Importer les joueurs", ImportActors())
        self.menu.add("auto", "Ajouter un nouveau joueur", Actors())
        self.menu.add("auto", "Modifier le classement d'un joueur",
                      ActorsRank())
        self.menu.add("auto",
                      "Retour au menu principal et sauvegarder les joueurs",
                      ExportActors(Actors.actors.values()))
        self.menu.add("auto",
                      "Retour au menu principal sans sauvegarder les joueurs",
                      HomeMenuController())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #4
0
class ActorsList:
    """ Defines a menu to obtain the actors lists """
    def __init__(self):
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        self.menu.add("auto", "Trier par ordre alphabétique",
                      ActorsListAlphabetical())
        self.menu.add("auto", "Trier selon leur classement", ActorsListRank())
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #5
0
class ReportMenu:
    """
    Defines a menu between the different reports
    """
    def __init__(self):
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        self.menu.add("auto", "Liste des acteurs", ActorsList())
        self.menu.add("auto", "Liste des tournois", TournamentsList())
        self.menu.add("auto", "Rapports pour un tournoi",
                      TournamentReportInput())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #6
0
class TournamentRoundsList:
    """ Displays the report of the rounds of a tournament """
    def __init__(self, tournament):
        self.tournament = tournament
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        report_tournament_rounds(self.tournament)
        self.menu.add("auto", "Retour au menu rapport du tournoi",
                      TournamentReportMenu(self.tournament))
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #7
0
class HomeMenuController:
    """ Handles the main menu. """
    def __init__(self):
        """
        The attribute menu is a instance of Menu, the option are added in __call__.
        The attribute view handles the display of the menu.
        """
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        """ Calls the display of the menu's introduction.
        The menu is created and the get_user_choice method
        asks for the user choice.
        """
        view_intro_home_menu()
        self.menu.add("auto", "Rentrer ou modifier des joueurs", ActorsMenu())
        self.menu.add("auto", "Lancer un tournoi", TournamentCreation())
        self.menu.add("auto", "Reprendre un tournoi", ResumeTournament())
        self.menu.add("auto", "Obtenir un rapport", ReportMenu())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #8
0
class ActorsListRank:
    """ Handles the list of actors in rank order """
    def __init__(self):
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        handler = DataBaseHandler()
        num_actors, actors_list = handler.import_actors()
        report_actors_by_rank(actors_list)
        self.menu.add("auto", "Retour au choix du tri", ActorsList())
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #9
0
class TournamentPlayersMenu:
    """ Defines a menu to input the players of the tournament. """
    def __init__(self, tournament):
        self.tournament = tournament
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        view_tournament_players(self.tournament)

        self.menu.add("auto", "Ajouter les joueurs par leur identifiant",
                      TournamentPlayers(self.tournament))
        self.menu.add("auto", "Interrompre le tournoi",
                      TournamentPause(self.tournament))
        self.menu.add("auto", "Retour au Menu Principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #10
0
class PlayersList:
    """ Displays the list of the players of a tournament.

    The argument sort is equal to "By rank" or "Alphabetical"
     so, the players are ranked according to this.

    """
    def __init__(self, tournament, sort):
        self.tournament = tournament
        self.sort = sort
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        report_tournament_players(self.tournament, self.sort)
        self.menu.add("auto", "Retour au choix du tri",
                      TournamentPlayersList(self.tournament))
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #11
0
class TournamentsList:
    """ Handles the list of tournaments """
    def __init__(self):
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        handler = DataBaseHandler()
        tournaments = handler.import_tournaments()
        report_tournaments_list(tournaments)
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #12
0
class TournamentPause:
    """ Defines a Pause menu

    Defines a menu to give the alternative of interrupting
    or continuing the tournament

    """
    def __init__(self, tournament):
        self.tournament = tournament
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        self.menu.add("auto", "Continuer et passer au tour suivant",
                      LaunchTournament(self.tournament))
        self.menu.add("auto", "Changer le classement d'un joueur",
                      ActorsRank(TournamentPause(self.tournament)))
        self.menu.add("auto", "Interrompre le tournoi",
                      TournamentInterruption(self.tournament))

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #13
0
class TournamentReportMenu:
    """ Handles the menu of reports of a tournament"""
    def __init__(self, tournament):
        self.tournament = tournament
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        view_tournament_reports(self.tournament)
        self.menu.add("auto", "Liste des joueurs du tournoi",
                      TournamentPlayersList(self.tournament))
        self.menu.add("auto", "Liste des matchs du tournoi",
                      TournamentMatchesList(self.tournament))
        self.menu.add("auto", "Liste des tours du tournoi",
                      TournamentRoundsList(self.tournament))
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #14
0
 def __init__(self):
     self.menu = Menu()
     self.view = MenuView(self.menu)
Пример #15
0
 def __init__(self, tournament):
     self.tournament = tournament
     self.menu = Menu()
     self.view = MenuView(self.menu)
Пример #16
0
class TournamentPlayersList:
    """ Displays the report of the players of a tournament """
    def __init__(self, tournament):
        self.tournament = tournament
        self.menu = Menu()
        self.view = MenuView(self.menu)

    def __call__(self):
        self.menu.add("auto", "Trier par ordre alphabétique",
                      PlayersList(self.tournament, "Alphabetical"))
        self.menu.add("auto", "Trier selon leur classement",
                      PlayersList(self.tournament, "By rank"))
        self.menu.add("auto", "Retour au menu rapport du tournoi",
                      TournamentReportMenu(self.tournament))
        self.menu.add("auto", "Obtenir un autre rapport", ReportMenu())
        self.menu.add("auto", "Retour au Menu principal", HomeMenuController())
        self.menu.add("q", "Quitter", Ending())

        user_choice = self.view.get_user_choice()
        return user_choice.next_menu
Пример #17
0
 def __init__(self, next_menu=ActorsMenu()):
     self.menu = Menu()
     self.view = MenuView(self.menu)
     self.next_menu = next_menu