Beispiel #1
0
 def start_tournament(self):
     """
     Updates the start_date attribute of the selected tournament.
     Calls the DBChess object to save the the selected tournament in the ongoing_tournament table and remove it
     from the planned_tournament table.
     """
     self.confirm(self.planned_tour_management)
     self.t_obj.start_date = datetime.now().strftime("%d/%m/%Y à %Hh%M")
     db.save_tournament(2, self.t_obj.name, self.t_obj.place,
                        self.t_obj.start_date, self.t_obj.end_date,
                        self.t_obj.time_control, self.t_obj.description,
                        self.t_obj.players_index_list,
                        self.t_obj.rounds_list)
     db.remove_tournament(1, self.t_obj.id)
     self.view_tournament.tournament_started()
     self.tournament_menu()
Beispiel #2
0
 def round_over(self, match_info_list, current_round_number):
     """
     Controls if the user input matches one the match number (to correct a match result) OR 'NEXT'
     (to access the ranking display).
     If 'NEXT', checks if a new round needs to be generated or if the tournament needs to be closed and saved in
     the corresponding DBChess Table.
     """
     while True:
         display_ranking_available = self.view_tournament.display_ranking_available(
         )
         self.back_or_exit(display_ranking_available,
                           self.ongoing_tournament_list)
         try:
             self.single_match_access(display_ranking_available,
                                      match_info_list, current_round_number)
         except ValueError:
             if display_ranking_available == 'NEXT':
                 self.t_obj.round_completion()
                 self.view_tournament.ranking_display(
                     self.t_obj.name, self.t_obj.total_rounds_number,
                     self.t_obj.rounds_list[-1].round_number,
                     self.t_obj.tournament_players_list)
                 if len(self.t_obj.rounds_list
                        ) < self.t_obj.total_rounds_number:
                     self.view_tournament.next_round_or_end(
                         self.t_obj.total_rounds_number,
                         self.t_obj.rounds_list[-1].round_number)
                     self.t_obj.new_round()
                     db.update_ongoing_tournament(self.t_obj.rounds_list,
                                                  self.t_obj_id)
                     self.check_tournament_status()
                 else:
                     db.save_tournament(
                         3, self.t_obj.name, self.t_obj.place,
                         self.t_obj.start_date, self.t_obj.end_date,
                         self.t_obj.time_control, self.t_obj.description,
                         self.t_obj.players_index_list,
                         self.t_obj.rounds_list)
                     db.remove_tournament(2, self.t_obj_id)
                     self.view_tournament.next_round_or_end(
                         self.t_obj.total_rounds_number,
                         self.t_obj.rounds_list[-1].round_number)
                     self.tournament_menu()
             else:
                 self.view_tournament.invalid_input()
Beispiel #3
0
 def ongoing_tour_management(self):
     """
     Calls the reconstructor object to build the selected tournament object.
     Calls the ongoing_tournament_management display from the ViewTournament object and controls the user input to
     continue or remove the tournament from the database using the DBChess object.
     """
     self.t_obj = reconstructor.create_tournament_obj(2, self.t_obj_id)
     self.t_obj.total_points_count()
     while True:
         continue_or_cancel = self.view_tournament.ongoing_tournament_management(
             [self.t_obj], self.t_obj.tournament_players_list)
         self.back_or_exit(continue_or_cancel, self.ongoing_tournament_list)
         if continue_or_cancel == '1':
             self.check_tournament_status()
         elif continue_or_cancel == '2':
             self.confirm(self.ongoing_tour_management)
             db.remove_tournament(2, self.t_obj_id)
             self.ongoing_tournament_list()
Beispiel #4
0
 def planned_no_player_list(self, players_index_list):
     """
     Calls the planned_tournament_management display method from the ViewTournament object.
     Redirects to register_player self method or remove_tournament from DBChess object depending on the user input.
     """
     while True:
         planned_tour_management = self.view_tournament.planned_tournament_management(
             [self.t_obj], players_index_list)
         self.back_or_exit(planned_tour_management,
                           self.planned_tournament_list)
         if planned_tour_management == '1':
             self.register_player()
         elif planned_tour_management == '2':
             self.confirm(planned_tour_management)
             db.remove_tournament(1, self.t_obj.id)
             self.ongoing_tournament_list()
         else:
             self.view_tournament.invalid_input()