moved some methods to view
This commit is contained in:
parent
425c5c716b
commit
195c3f6b02
@ -67,20 +67,18 @@ class Controller:
|
||||
|
||||
self.round.start_time = self.round.get_time()
|
||||
self.round.match_list = self.create_match()
|
||||
|
||||
print("Liste des joueurs, après tri : ", self.tournament.players_list)
|
||||
print("Liste des matchs du Round : ", self.round.match_list)
|
||||
#self.view.prompt_for_scores()
|
||||
print("saisir les scores :")
|
||||
self.view.prompt_for_scores()
|
||||
self.round.end_time = self.round.get_time()
|
||||
self.view.input_scores(self.round.match_list)
|
||||
# append self.tournament.round_list with [round, match_list]
|
||||
self.sort_by_score()
|
||||
self.view.display_round_info(self.round)
|
||||
self.view.display_scores(self.tournament.players_list)
|
||||
|
||||
print("Le tournoi", self.tournament.name, "est terminé !")
|
||||
|
||||
|
||||
|
||||
print("scores du round :\n")
|
||||
for i in self.tournament.players_list:
|
||||
print(i.ine, " : ", i.score)
|
||||
|
||||
input("Continuer ?")
|
||||
|
||||
|
||||
def create_match(self):
|
||||
@ -101,15 +99,6 @@ class Controller:
|
||||
|
||||
return self.round.match_list
|
||||
|
||||
def record_new_player(self):
|
||||
print("Enregistrez un nouveau joueur :\n")
|
||||
self.lastname = input("Nom de famille ? : ")
|
||||
self.name = input("Prénom ? : ")
|
||||
self.birthdate = input("Date de naissance (jj/mm/aaaa) ? : ")
|
||||
#self.birthdate = self.check_date()
|
||||
self.ine = input("Identifiant National d'Echecs (ine) ? : ")
|
||||
#self.ine = self.test_ine()
|
||||
return {"Nom": self.lastname, "Prénom": self.name, "Date de naissance": self.birthdate, "INE": self.ine}
|
||||
|
||||
|
||||
def run(self):
|
||||
@ -119,18 +108,13 @@ class Controller:
|
||||
elif menu_choice == "3":
|
||||
self.menu.items(2)
|
||||
elif menu_choice == "2":
|
||||
self.record_new_player()
|
||||
self.view.prompt_for_new_player()
|
||||
elif menu_choice == "1":
|
||||
print("c'est parti")
|
||||
self.create_tournament()
|
||||
self.run_tournament()
|
||||
print("Tournoi terminé.\n Les scores sont :\n")
|
||||
for i in self.tournament.players_list:
|
||||
print(i.ine, " : ", i.score)
|
||||
|
||||
|
||||
|
||||
|
||||
self.view.display_winner(self.tournament.players_list)
|
||||
self.view.display_scores(self.tournament.players_list)
|
||||
|
||||
|
||||
run = Controller()
|
||||
|
@ -41,10 +41,10 @@ class Match:
|
||||
def __str__(self):
|
||||
#return self.player1.name + " " + self.player1.lastname + " / " + self.player2.name + " " + self.player2.lastname
|
||||
return self.player1.ine + "/" + self.player2.ine
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
def create(self):
|
||||
pass
|
||||
|
||||
|
@ -6,14 +6,6 @@ class View:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def prompt_for_scores(self):
|
||||
print()
|
||||
input("Saisir les scores ?")
|
||||
return True
|
||||
|
||||
def display_winner(self, participants):
|
||||
pass
|
||||
|
||||
def check_date(self):
|
||||
while True:
|
||||
date = input("Date de naissance (jj/mm/aaaa) ? : ")
|
||||
@ -22,7 +14,6 @@ class View:
|
||||
else:
|
||||
print("La date doit être au format jj/mm/aaaa")
|
||||
|
||||
|
||||
def test_ine(self):
|
||||
ine_pattern = r'[a-zA-Z]{2}\d{5}'
|
||||
while True:
|
||||
@ -32,6 +23,28 @@ class View:
|
||||
else:
|
||||
print("Mauvais format d'ine")
|
||||
|
||||
def prompt_for_scores(self):
|
||||
print()
|
||||
input("Saisir les scores ?")
|
||||
return True
|
||||
|
||||
def display_round_info(self, round):
|
||||
print("Infos du round", round.name, "début le", round.start_time, "fin le", round.end_time, ":\n")
|
||||
|
||||
def display_scores(self, players_list):
|
||||
print("Les scores sont :\n")
|
||||
for i in players_list:
|
||||
print(i.ine, i.name, i.lastname, " : ", i.score)
|
||||
|
||||
def prompt_for_new_player(self):
|
||||
print("Enregistrez un nouveau joueur :\n")
|
||||
self.lastname = input("Nom de famille ? : ")
|
||||
self.name = input("Prénom ? : ")
|
||||
self.birthdate = input("Date de naissance (jj/mm/aaaa) ? : ")
|
||||
#self.birthdate = self.check_date()
|
||||
self.ine = input("Identifiant National d'Echecs (ine) ? : ")
|
||||
#self.ine = self.test_ine()
|
||||
return {"Nom": self.lastname, "Prénom": self.name, "Date de naissance": self.birthdate, "INE": self.ine}
|
||||
|
||||
def input_scores(self, match_list):
|
||||
for match in match_list:
|
||||
@ -54,4 +67,16 @@ class View:
|
||||
except ValueError:
|
||||
print("Veuillez entrer un chiffre")
|
||||
|
||||
def display_winner(self, player_list):
|
||||
winner = max(player_list, key=lambda t: t.score)
|
||||
print("Le gagnant est :", winner.name, winner.lastname, "avec un score de :", winner.score)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user