push all to show in first session

This commit is contained in:
yann 2025-01-23 09:43:02 +01:00
commit 78cdc9028e
10 changed files with 166 additions and 0 deletions

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# work in progress

40
main.py Normal file
View File

@ -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()

0
tournoi/__init_.py Normal file
View File

0
tournoi/match.py Normal file
View File

14
tournoi/menu.py Normal file
View File

@ -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')

19
tournoi/player.py Normal file
View File

@ -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()

10
tournoi/players.json Normal file
View File

@ -0,0 +1,10 @@
{
"lastname": "Prout",
"name": "Joe",
"birth_date": "23/02/2003"
}
{
"lastname": "Dupont",
"name": "Pierre",
"birth_date": "20/01/2002"
}

0
tournoi/tournament.py Normal file
View File

74
tournoi/turn.py Normal file
View File

@ -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()

7
vrac.py Normal file
View File

@ -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)])