From 6e476e8301bf1d14dab1c04d18da795c2ddce7e7 Mon Sep 17 00:00:00 2001 From: yann Date: Fri, 31 Jan 2025 10:42:24 +0100 Subject: [PATCH] kind of works, show winner(but not if equals) --- models/participant.py | 2 +- player_list.json | 2 +- vrac.py | 12 +++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/models/participant.py b/models/participant.py index 468dc33..9c9b14c 100644 --- a/models/participant.py +++ b/models/participant.py @@ -8,7 +8,7 @@ class Participants(UserDict): takes tournament's name and list of object Player returns dict with player: score""" - def __init__(self, player_list): #player_list FOR TEST ; to feed when creating object + def __init__(self, player_list=None): #player_list FOR TEST ; to feed when creating object #self.tournament self.player_list = player_list self.data = {} diff --git a/player_list.json b/player_list.json index 0eea98e..b863ffd 100644 --- a/player_list.json +++ b/player_list.json @@ -1 +1 @@ -{"EF34924": ["Bob", "Durand", "25/12/1995", "M"], "QS42622": ["Joe", "Bidjoba", "02/01/2001", "M"], "AB20022": ["Jeanine", "Mequesurton", "25/12/1995", "F"], "JF78739": ["Jean-Pierre", "Quiroul", "15/09/1992", "M"], "ED22230": ["Ren\u00e9", "Nuphard", "25/12/1995", "M"], "EE49948": ["Sophie", "Fonfec", "24/05/1999", "F"]} \ No newline at end of file +{"EF34924": ["Bob", "Durand", "25/12/1995", "M"], "QS42622": ["Joe", "Bidjoba", "02/01/2001", "M"], "AB20022": ["Jeanine", "Mequesurton", "25/12/1995", "F"], "JF78739": ["Jean-Pierre", "Quiroul", "15/09/1992", "M"], "ED22230": ["Ren\u00e9", "Nuphard", "25/12/1995", "M"], "EE49948": ["Sophie", "Fonfec", "24/05/1999", "F"], "JG43857": ["Gérard", "Pala", "15/03/2011", "M"], "UD47293": ["Géraldine", "Palelundi", "12/05/1999", "F"]} diff --git a/vrac.py b/vrac.py index 3923e64..330ed2e 100644 --- a/vrac.py +++ b/vrac.py @@ -138,20 +138,26 @@ def test3(): tour.input_scores() print("Save \n", tour.name, tour.match_result) tournoi1.turn_list.append([tour.name, tour.match_result]) + print(tour.name) def display_winner(participants): - base = - for i in participants: - if participants[i] + pass +# liste = tour.sort_player_by_score +# for i in participants: +# if participants[i] print("Début du", tournoi1.name, "!") while turn_nb < tournoi1.total_turn: tournoi1.current_turn = turn_nb run_turn(turn_nb) turn_nb += 1 + #scores = sorted(participants.items(), key=lambda t: t[1]) + winner = max(participants, key = participants.get) + print("participants.get", participants.get) print("\nLe", tournoi1.name, "est terminé.\n") print("Scores finaux:\n", participants.data) + print("Le vainqueur est :\n", winner) print("liste des tours:\n", tournoi1.turn_list) #for i in range(1, tournoi1.total_turn+1):