remove prints and inputs from controller to view
This commit is contained in:
parent
c9cf13c209
commit
aea638d660
@ -7,8 +7,8 @@ import json
|
||||
|
||||
|
||||
class Save:
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self, view):
|
||||
self.view = view
|
||||
|
||||
def load_file(self, file):
|
||||
try:
|
||||
@ -22,7 +22,7 @@ class Save:
|
||||
return data_tmp
|
||||
|
||||
except json.decoder.JSONDecodeError:
|
||||
print("Erreur de format sur le fichier")
|
||||
self.view.display_format_error()
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
@ -37,7 +37,7 @@ class Save:
|
||||
data_tmp = (self.load_file(PLAYERFILE))
|
||||
data_tmp.append(player)
|
||||
self.write_file(data_tmp, PLAYERFILE)
|
||||
print("Joueur créé !")
|
||||
self.view.player_ok()
|
||||
return True
|
||||
|
||||
def player_load(self) -> list:
|
||||
@ -55,7 +55,7 @@ class Save:
|
||||
|
||||
return data_list
|
||||
else:
|
||||
print("\n**** Pas de fichier joueur trouvé :/\n")
|
||||
self.view.display_file_error("joueur")
|
||||
|
||||
def tournament_write(self, tournament):
|
||||
data = {
|
||||
@ -74,7 +74,7 @@ class Save:
|
||||
data_tmp = self.load_file(TOURNAMENTFILE)
|
||||
return data_tmp
|
||||
else:
|
||||
print("\n**** Pas de fichier tournoi trouvé :/ \n")
|
||||
self.view.display_file_error("tournoi")
|
||||
|
||||
|
||||
class Application:
|
||||
@ -91,7 +91,6 @@ class Application:
|
||||
|
||||
def create_tournament(self):
|
||||
"""update existing tournament with data from view"""
|
||||
print("Nouveau tournoi ! \n")
|
||||
tournament_details = self.view.prompt_for_tournament()
|
||||
self.tournament.name = tournament_details['name']
|
||||
self.tournament.location = tournament_details['location']
|
||||
@ -133,7 +132,7 @@ class Application:
|
||||
self.view.display_round_info(self.round)
|
||||
self.view.display_scores(self.tournament.players_list)
|
||||
|
||||
print("\nLe tournoi", self.tournament.name, "est terminé !\n")
|
||||
self.view.ok_done(self.tournament.name)
|
||||
|
||||
def check_match(self, match, match_history):
|
||||
"""check if match is in list
|
||||
@ -161,7 +160,7 @@ class Application:
|
||||
match.player2 = self.tournament.players_list[i+1]
|
||||
if self.match_history.check(match):
|
||||
# match.player2 = self.tournament.players_list[i+2]
|
||||
print("deja joue")
|
||||
self.view.display_error_already()
|
||||
match_list.append(match)
|
||||
except IndexError:
|
||||
pass
|
||||
@ -195,7 +194,7 @@ class Application:
|
||||
while True:
|
||||
# Quit
|
||||
if menu_choice == "4":
|
||||
print("Bye")
|
||||
self.view.display_quit()
|
||||
quit()
|
||||
# Rapports
|
||||
elif menu_choice == "3":
|
||||
@ -209,14 +208,14 @@ class Application:
|
||||
elif rapport_choice == "1":
|
||||
if self.save.player_load():
|
||||
self.view.display_players(self.save.player_load())
|
||||
input("?")
|
||||
self.view.prompt_next()
|
||||
|
||||
# Display list of tournaments
|
||||
elif rapport_choice == "2":
|
||||
if self.save.tournament_load():
|
||||
self.view.display_tournaments(
|
||||
self.save.tournament_load())
|
||||
input("?")
|
||||
self.view.prompt_next()
|
||||
|
||||
# display tournament's details
|
||||
elif rapport_choice == "3":
|
||||
@ -234,12 +233,12 @@ class Application:
|
||||
elif menu_choice == "2":
|
||||
joueur = self.view.prompt_for_new_player()
|
||||
self.save.player_write(joueur)
|
||||
input("Retour ?")
|
||||
self.view.prompt_next()
|
||||
self.menu_manager()
|
||||
|
||||
# create new tournament
|
||||
elif menu_choice == "1":
|
||||
print("c'est parti")
|
||||
self.view.ok_go()
|
||||
self.create_tournament()
|
||||
self.run_tournament()
|
||||
self.menu_manager()
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div id="masthead" class="sev-4"></div>
|
||||
<div id="page">
|
||||
<h1>flake8 violations</h1>
|
||||
<p id="versions">Generated on 2025-02-13 19:02
|
||||
<p id="versions">Generated on 2025-02-14 11:49
|
||||
with Installed plugins: flake8-html: 0.4.3, mccabe: 0.7.0, pycodestyle: 2.12.1, pyflakes: 3.2.0
|
||||
</p>
|
||||
<ul id="index">
|
||||
|
2
main.py
2
main.py
@ -6,8 +6,8 @@ from views.menu import Menu
|
||||
|
||||
def main():
|
||||
tournament = Tournament()
|
||||
save = Save()
|
||||
view = View()
|
||||
save = Save(view)
|
||||
menu = Menu()
|
||||
application = Application(tournament=tournament,
|
||||
save=save,
|
||||
|
@ -29,6 +29,11 @@ class View:
|
||||
input("Saisir les scores ? (y)")
|
||||
return True
|
||||
|
||||
def prompt_next(self):
|
||||
print()
|
||||
input("?")
|
||||
return True
|
||||
|
||||
def prompt_for_round(self, round):
|
||||
print()
|
||||
input(f"Prêt à lancer le {round.name} ? (y)")
|
||||
@ -141,7 +146,28 @@ class View:
|
||||
def display_error(self):
|
||||
print("Erreur de saisie, recommencez;")
|
||||
|
||||
def display_format_error(self):
|
||||
print("\n**** Erreur de format de fichier")
|
||||
|
||||
def display_file_error(self, file):
|
||||
print(f"\n**** Pas de fichier {file} trouvé :/")
|
||||
|
||||
def display_player_instructions(self):
|
||||
print("Placez un fichier joueur dans le répertoire data "
|
||||
"ou créez des nouveaux joueurs depuis le menu")
|
||||
print()
|
||||
|
||||
def display_quit(self):
|
||||
print("Bye !")
|
||||
|
||||
def display_error_already(self):
|
||||
print("Déjà joué")
|
||||
|
||||
def ok_player(self):
|
||||
print("\nJoueur créé.")
|
||||
|
||||
def ok_go(self):
|
||||
print("\n!!! C'est parti !!!\n")
|
||||
|
||||
def ok_done(self, name):
|
||||
print(f"\nLe tournoi {name} est terminé !\n")
|
||||
|
Loading…
x
Reference in New Issue
Block a user