コード例 #1
0
ファイル: tournament.py プロジェクト: mentorat/tournament
 def get_next_round(self, tournament, rounds, players):
     """Create Round 2, 3 , 4."""
     print(f"\n*******************ROUND {len(rounds)+1}******************\n")
     round = Round(
         f"Round {len(rounds) + 1}",
         datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"),
         matchs=[],
     )
     players = sorted(
         sorted(
             players,
             key=lambda player: player.rank,
         ),
         key=lambda player: player.points,
         reverse=True,
     )
     print(players)
     round.get_opponents(players)
     for player in players:
         add_point = Input.for_score(
             f"\n Please enter {player.first_name}'s score : "
         )
         player.add_points(add_point)
     round.end = str(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
     rounds.append(round)
     print(f"\n{round}")
     return round
コード例 #2
0
 def get_first_round(self, rounds, players):
     """Create the first round of a tournament."""
     print(
         f"\n*******************ROUND {len(rounds)+1}******************\n")
     round = Round(
         f"Round {len(rounds)+ 1}",
         datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"),
         matchs=[],
     )
     players = sorted(players, key=lambda player: player.rank)
     nb_matchs = 4
     for index in range(nb_matchs):
         print(
             f"{players[index].first_name} vs {players[index+4].first_name}"
         )
     self.get_first_opponents(players)
     for player in players:
         add_point = Input.for_score(
             f"Please enter {player.first_name}'s score : ")
         player.add_points(add_point)
     Round.display_first_matchs(round, players)
     round.end = str(datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S"))
     rounds.append(round)
     print(f"\n{round}")
     return round