commit 78cdc9028e995ccfd561b75b185934db762862a7 Author: yann Date: Thu Jan 23 09:43:02 2025 +0100 push all to show in first session diff --git a/README.md b/README.md new file mode 100644 index 0000000..aef916a --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ + +# work in progress diff --git a/main.py b/main.py new file mode 100644 index 0000000..9922a62 --- /dev/null +++ b/main.py @@ -0,0 +1,40 @@ + +def main(): + + +#Menu +## creer un nouveau tournoi + +## enregistrer un nouveau joueur + +## rapport +### afficher la liste des joueurs inscrits +### liste des tournois +### afficher un tounroi en particulier : +#### liste des joueurs du tournoi (alphab.) +#### liste des tours, matchs + + +# Nouveau Tournoi : +## entrer les infos : +## nom, lieu, date début, date fin, nombre de tours(opt) + +# Participants / joueurs : +## besoin d'enregistrer des nouveaux joueurs ? +## selection des participant dans la liste des joueurs du club + +## Creation du 1er tour : affichage du tour, de la liste des matchs (paire nom.prenom) : +## En attente saisie séquentielle des résultats pour chaque match : +### Saisie résultat match 1 : 1. Bob LEPONGE / 2. Bernard DINAMOUK / 3.Match Nul +### ? + +## Tour suivant (puis itération) : affichage du tour, de la liste des matchs (paire nom.prenom) : +## etc + +## Après le dernier tour : affichage du vainqueur +## sauvegarde du tournoi : tournois/{date.nom.lieu}/{date.nom.lieu}.json, matchs.json +## + +if __name__ == "__main__" : + main() + diff --git a/tournoi/__init_.py b/tournoi/__init_.py new file mode 100644 index 0000000..e69de29 diff --git a/tournoi/match.py b/tournoi/match.py new file mode 100644 index 0000000..e69de29 diff --git a/tournoi/menu.py b/tournoi/menu.py new file mode 100644 index 0000000..38c347d --- /dev/null +++ b/tournoi/menu.py @@ -0,0 +1,14 @@ +class Menu: + + def items(self): + print("[1] Créer un nouveau tournoi", end='\n') + print("[2] Enregistrer un nouveau joueur", end='\n') + print("[3] Rapports", end='\n') + print("[4] Quitter", end='\n') + + + def rapports(): + print("[1] Afficher la liste des joueurs", end='\n') + print("[2] Afficher l'historique des tournois", end='\n') + print("[3] Afficher le détail d'un tournoi", end='\n') + print("[4] Quitter", end='\n') diff --git a/tournoi/player.py b/tournoi/player.py new file mode 100644 index 0000000..d64df1e --- /dev/null +++ b/tournoi/player.py @@ -0,0 +1,19 @@ +import json + +class Player: + """Define player, should store only data for now ? Don't see further""" + + def get_new_player(self): + get_player = {} + print("Enregistrez un nouveau joueur :\n") + get_player['lastname'] = input('Nom de famille :\n') + get_player['name'] = input('Prénom :\n') + get_player['birth_date'] = input('Date de naissance :\n') + + #convert dict in json object and write it in players.json file (with "a" append to file) + with open("players.json", "a") as output: + output.write(json.dumps(get_player, indent=3)) + + +new = Player() +new.get_new_player() diff --git a/tournoi/players.json b/tournoi/players.json new file mode 100644 index 0000000..27e7345 --- /dev/null +++ b/tournoi/players.json @@ -0,0 +1,10 @@ +{ + "lastname": "Prout", + "name": "Joe", + "birth_date": "23/02/2003" +} +{ + "lastname": "Dupont", + "name": "Pierre", + "birth_date": "20/01/2002" +} \ No newline at end of file diff --git a/tournoi/tournament.py b/tournoi/tournament.py new file mode 100644 index 0000000..e69de29 diff --git a/tournoi/turn.py b/tournoi/turn.py new file mode 100644 index 0000000..c48c80b --- /dev/null +++ b/tournoi/turn.py @@ -0,0 +1,74 @@ +from random import choice + + +class Turn(): + def __init__(self, name, matchs): + self.name = name + self.matchs = matchs + self.match_history = [] + + def rambling(self, player_list): + """jumble (random order) players in list and return list""" + self.tmp_list = [] + self.picked_player = [] + for i in range(2^len(player_list)): + self.picked_player = choice(player_list) + self.tmp_list.append(self.picked_player) + return self.tmp_list + + + def sorting(self, player_list): + """order players on score : use second index (for every item in the list) as key (given by function score)""" + def score(couple): + return couple[1] + return sorted(player_list, key=score) + + + def associate(self, player_list): + """create a match list""" + self.match_list = [] + self.couple = () + for i in range(len(player_list)): + if i % 2 == 0 : + self.couple = (player_list[i][0], player_list[i+1][0]) + if self.couple in self.match_history: + self.couple = (player_list[i][0], player_list[i + 2][0]) + self.match_list.append(self.couple) + else: + self.match_list.append(self.couple) + + self.match_history.append(self.name) + self.match_history.append(self.match_list) + return self.match_list + + + def matchmarking(self, player_list): + pass + +list = [['Player1', 8], + ['Player2', 2], + ['Player3', 0], + ['Player4', 5], + ['Player5', 8], + ['Player6', 3], + ['Player7', 1], + ['Player8', 6], + ['Player9', 3], + ['Player10', 4], + ['Player11', 3], + ['Player12', 2], + ['Player13', 8], + ['Player14', 4], + ['Player15', 2], + ['Player16', 7]] + +tour = Turn("tour1", 1) + +print(tour.sorting(list)) +print(tour.rambling(list)) + +print(tour.associate(tour.sorting(list))) + +print(f"Voici l'historique des matchs : {tour.match_history}") + +tour2 = Turn() \ No newline at end of file diff --git a/vrac.py b/vrac.py new file mode 100644 index 0000000..ca61ba2 --- /dev/null +++ b/vrac.py @@ -0,0 +1,7 @@ +# generate player list +from random import randint + +list = [] +for i in range(16): + list.append(["Player"+str(i+1), randint(0, 8)]) +