From 471b2c9692019d78bdc24485d8cdaf1bc3b8b69b Mon Sep 17 00:00:00 2001 From: yann Date: Thu, 30 Jan 2025 17:14:46 +0100 Subject: [PATCH] refactor with MVC folder; tests in vrac.py for now --- controllers/__init__.py | 0 .../__pycache__/__init__.cpython-310.pyc | Bin 0 -> 162 bytes controllers/__pycache__/base.cpython-310.pyc | Bin 0 -> 1646 bytes controllers/base.py | 61 +++++++ data/players/player_list.json | 1 + main.py | 43 ++--- models/__pycache__/match.cpython-310.pyc | Bin 0 -> 1174 bytes .../__pycache__/participant.cpython-310.pyc | Bin 0 -> 1982 bytes models/__pycache__/player.cpython-310.pyc | Bin 0 -> 878 bytes models/__pycache__/tournament.cpython-310.pyc | Bin 0 -> 1029 bytes models/__pycache__/turn.cpython-310.pyc | Bin 0 -> 2955 bytes models/match.py | 27 ++++ models/participant.py | 49 ++++++ models/player.py | 20 +++ models/scorelist.py | 4 + models/tournament.py | 31 ++++ models/turn.py | 74 +++++++++ player_list.json | 1 + tournoi/menu.py | 14 -- tournoi/player.py | 19 --- views/__pycache__/base.cpython-310.pyc | Bin 0 -> 637 bytes views/base.py | 9 ++ views/menu.py | 33 ++++ vrac.py | 151 +++++++++++++++++- 24 files changed, 467 insertions(+), 70 deletions(-) create mode 100644 controllers/__init__.py create mode 100644 controllers/__pycache__/__init__.cpython-310.pyc create mode 100644 controllers/__pycache__/base.cpython-310.pyc create mode 100644 controllers/base.py create mode 100644 data/players/player_list.json create mode 100644 models/__pycache__/match.cpython-310.pyc create mode 100644 models/__pycache__/participant.cpython-310.pyc create mode 100644 models/__pycache__/player.cpython-310.pyc create mode 100644 models/__pycache__/tournament.cpython-310.pyc create mode 100644 models/__pycache__/turn.cpython-310.pyc create mode 100644 models/match.py create mode 100644 models/participant.py create mode 100644 models/player.py create mode 100644 models/scorelist.py create mode 100644 models/tournament.py create mode 100644 models/turn.py create mode 100644 player_list.json delete mode 100644 tournoi/menu.py delete mode 100644 tournoi/player.py create mode 100644 views/__pycache__/base.cpython-310.pyc create mode 100644 views/base.py create mode 100644 views/menu.py diff --git a/controllers/__init__.py b/controllers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/controllers/__pycache__/__init__.cpython-310.pyc b/controllers/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9401fc4e1157ccc2478717dcd3ed85317234a6a9 GIT binary patch literal 162 zcmd1j<>g`k0K0Y%q dvm`!Vub}c4hfQvNN@-529mx1%CLqDW000-vCk+4q literal 0 HcmV?d00001 diff --git a/controllers/__pycache__/base.cpython-310.pyc b/controllers/__pycache__/base.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1834512f965ff03635677011a84049cf946671f4 GIT binary patch literal 1646 zcmaJB%WfP+u)F86`9H}V&K<-{*=301vzJP<*Tx~8hSy580G#zshBeLDDg`kPP4A4qhU z1H>+D^$7q@I4wv?$CM(@3RXH}$Kp=mmfqN-$BvjE=6*X+^Z)I=0PQ2 z?tPWaWjz!6X0mrAl)6k(GI<@1N)9q5hVxSsq-kE|I!$|^P+|3a=F@-$G<4eS%lL;E za{rwObZJ3m*B(9E&+Wl0#~HDENsyM+tukvLNGvuTbb?DnABp zV0qpJPep(+*beNK9|`SPrSGi3ZDB#b(My$xIK0%+GXBys_Py z>R_mpJS7!9A=qm_(C1`f)3Bi6sMB8iT!?v;sc-XY3V!OmhnGBvb*TL`?*-DDnxsG1`4nal`+xeZ@EGf$*gB5!wKy5lNg$W=RbBl#vXGJ6K zOIb_f&1GI`>rLt-wqK`VEM0an6v18~XLmwDA zYOm~z??K{G@*o+-_RuvBl(fMaIWJ+m^@dL4JrvLxu`hQ(PQDGm1VyGazEQ@taP1(M z`p722pNfhL*_noS@S2^5E&1=bP@7Fiz(OyieYUwCvXF+ac6#l5|Cf+a?BkH5^)xkM znwB+h3dH+q`dyP1s}p$zjbp~;009nj2cTCHXAUP?VW$Qppuu|Ivs`@Fwm`8c)Ufk@ t*#~XooWH7%#Gy6o7qalQ*;meL>DaU8Z7PD>D~IpkqiZc=GxX_I_BVmqn!x}7 literal 0 HcmV?d00001 diff --git a/controllers/base.py b/controllers/base.py new file mode 100644 index 0000000..005953f --- /dev/null +++ b/controllers/base.py @@ -0,0 +1,61 @@ +from models.tournament import Tournament +from models.player import Player +from models.turn import Turn +from models.match import Match +from views.menu import Menu + +class Controller: + def __init__(self): + # loading models + self.players_list: List[Player] = [] + self.score_list = [] + + + + # loading views + self.view = Menu() + + #self.tournament = Tournament(name = "Tournoi de Cajou", ) + #self.turn = Turn() + def prompt_menu(self): + pass + + def record_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') + + self.lastname = input("Nom de famille ? :\n") + self.name = input("Prénom ? :\n") + + def input_date(date): + """Keep asking until date format is valid""" + try: + datetime.strptime(date, '%d/%m/%Y') + return date + except ValueError: + print("La date doit être au format jj/mm/aaaa") + new_date = input() + input_date(new_date) + return new_date + + self.birthdate = input_date(input("Date de naissance (jj/mm/aaaa) ?:\n")) + + while self.gender not in ("M", "F", "N"): + self.gender = input("Sexe (M/F/N) ?:\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)) + + return {"Nom": self.lastname, "Prénom": self.name, "Date de naissance": self.birthdate, "Genre": self.gender} + + def run(self): + + menu_choice = self.view.items(1) + if menu_choice == 3: + self.view.items(2) + + diff --git a/data/players/player_list.json b/data/players/player_list.json new file mode 100644 index 0000000..0eea98e --- /dev/null +++ b/data/players/player_list.json @@ -0,0 +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 diff --git a/main.py b/main.py index 9922a62..4a86937 100644 --- a/main.py +++ b/main.py @@ -1,40 +1,17 @@ +from controllers.base import Controller +from views.base import View + def main(): + view = View() + menu = Controller(view) + menu.run() -#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/models/__pycache__/match.cpython-310.pyc b/models/__pycache__/match.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7a63f515146c742b5871f1b4a5708811425c31e GIT binary patch literal 1174 zcmZuwOK%e~5VrS~ZJHonst|{2IiW~ZmsT7Ls#K(&2#Cie2wB^;n};^pU^`Tea%=xZ z#f2MxX|J643qA3THz^UVBag>BBB#5UUyl1W~$ zG4FBCj+ykNf61hO;q^Qjd}N*Q4}4gMSJC?-J6AfV>-zF=Im9+EAQbCy$?%l-{5n)G zkbw*@Sud24Y~YM!EH`jAWE0^xtMF}R^TAvkE1TG}GMTzGrrAuerg}KBNtPH3rJtM) z?I1ZRA%@a82d(T(PvBu^(?TWXX;KW0T?W}nOkQf`9CHG_TBOrH!ZrsGk}a5E3l7N_ z9wZPz`c4K5Ho|S>_hA{)4*K3Hd4-YzgV)s@F*;EdOtP`68a0Hym9k$&u8zIsxnBh` zvsuTl0;7sk9pbT$Abv5uiR1cJIw;2~JxSk``E0Bv)}-%_KBQA!j+A|w9u1T+pGx3H zwuw#0rBsDU$JEE&>3J0kF`Nvo5E}?)S`ZOm{kHl1o@@B-$|KF zuD}bN9H;*y1mvK5&A-gOo#dK-?RaYlxF+g37`34ERYM3&P>2V(7$VFTpSM?KILoan z$jem`L$Mgo1xH@q1rvR|(D(8A|1?RGYe;m}W~;7outkfx*uT(py4&n`On)f^N$)M=#oxi+Zjfk)W=u zwT!5yX*`-*K-+O8W&w}GIF9{R;4EDbwOw;;w`R7c;W*n};i~wcF6=e2$zf@+hu&W$ CH2cf| literal 0 HcmV?d00001 diff --git a/models/__pycache__/participant.cpython-310.pyc b/models/__pycache__/participant.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b8249c89c854cb81e8e858dbad08a1fa943269a6 GIT binary patch literal 1982 zcmaJ?&2HQ_5GEx`EANlnq)r0^Mye!-Ru?M)ate$hg`E}!0@sLJ6j`7kWRYuYqm|aA z7Dg7@lYMK8K0pt(k9j3td-5yv;?7WOd+jvkg2NF-&CK`B47cp{+62bvuRr%^9wC3@ z!{T7@@B*fO20{=)b26fRN>O)mr|-b(=I)5~871El!Gw20geU2-+xLXCOCtXqz9bPf z!B1MMtt_p!;lba@lXp_3_-=8y@bChrehxyCJ{1If(7r2r!WHa<_Q8YjPY76Vi2zn# zEQvO(EzuEOSOe>I*>rXiRb^>5PKs*!EBXz~K{&QRPA;Mqe|XNy|DYG4)L}9I?uGVSndra*lzIHuavC7j1C3*Jj$wrx!327$L-Vs zY?lLdoSQK98i<JV@y}*_P>y807jKp6 z1WD2H51X&!u_}kMdKPaUNUeXoVk{n&LgqRiU(>!merE#Cvm&cF?;yYcgzxy&r)@f2 zS;)}(<*^&&U^QR`E|9ZDehFq!5j7c-+8NRfatQPcksN1RQ8*kq3f-6>#Q=FGB3EIN zo7S8#!?H?_u7N5H&8($LCY9t1@$-QyN0!4CIH8fAfG$Ju)2|jo|Gy7YjOcP;o-s5F zX9JW9@;ju*^p8(wv~o_}nx0|a+0W2k41UKhHrg(EO7#6BXgd78fr)$X>2~B9R*q$% zmcW)_n0v$WG7**l;K9OXgDjV~(caycl||NI#3QR<#A56M#zz;^2a6a#JbnWiQiIMc zvfn`2Co`ztnRA7(H*+mQ_l(XQz(+6f6#<}IT|`$qkmPX2YI@2luXbv-3YX0)q}yul zl?MCsJr6V{{NKGZyqesZcNo^>)JHy{Fj~{P$x)ch`!uxOi|Gxk0~sQ7A#%{PJ+}Tt zL+9gGm=$3^GdWwoWf zOjQTapVIjIa3@KndU&#>?!sb|tUf~xtI_z$7*a138dINwhk4=P=k@0xn9pbzerp$j!{`&rE_@dn_TlY{_`t%AqCmhnH_J!FbJOM=?x;zQ zdYALVNs`asv^W=K%DL)da7d;?8q`A+k5F6(X*Ikt6hgwn*T{GPakW{n6nKHxy<^`+ xzUic8p2OcmRu)=e@HT;_*W8us4S!7v(b|8xF~LR?_1DOyy+ONh4Rz^?`!D_y-sk`T literal 0 HcmV?d00001 diff --git a/models/__pycache__/player.cpython-310.pyc b/models/__pycache__/player.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9e5348e00ed53626826c03228215cc984d9fec6f GIT binary patch literal 878 zcmZWny>8nu5I*XcR_z20y4UDXKpmo`V-XZ^fTD|AH0`2=utg@8p&yr|h8WtCx9Ah( zdAf1!)K}=#JE<|;mI6QC@x=S?KC+$762S5O{kNOv9>5QBj)#xVTb$-4f&|Gb$Z7Q| zR}&dWW?t{@G6;=iy=nd5S0l`U&k(9ZEVg~Mi|B}jY-|b^IL!-$p7kK0 z_Yhg{BYJ&+==ULFAmIug*fI@W(5!0Zc(pQiuqNwL+YL42q8rsnr5!Ie${10~G;)Da z)wK?hKog~o2{^$7;Q{m$Tz*|-o3>WjI=gI(u2zjT*@wlaY^U3;vahoR<@?-rniw0K z)vZ*O$#z4x=et|Sg(#cS3PBu(t}SBYm$3cmsK)u@KLx}1;~<;npaY%mVT-+{Y(M*A zl$@8%e5cFCrfe*jY05rSJ;D@S7Ykvm7Gj2uAz34Te{!H5LjSQI)F(A8^4{SC(E&R6 zI($5%Ptg9C2|Lwlhg4@69H{tlhhuEa5|b>Xm=G=z0!8a8vZq3P?N-&F2$n9}0<%)> z`jp`5-@J4~n%dO#GO55pVGaRH7>}pnu%G%a*qXM{)Yq_cRQe%><8Q_~E=Y7kf^(R% GGw(OpySJkN literal 0 HcmV?d00001 diff --git a/models/__pycache__/tournament.cpython-310.pyc b/models/__pycache__/tournament.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d700b76987cd0766c82fadb8f263ed99d61d483e GIT binary patch literal 1029 zcmY*Y&2H2%5VrH5Y%0+o4v0&{EgTvlaY6_c7Kz(Zm7a33(%7_tY@FJTP*=IpC*aBx z@JhaN>MQibOtwG4j=zjOlbLU39J#ZT5E#L)-{&t}LjK}rKH!WT!O|}QIN`JG6d7Jh-OdJ>=0fDSaM8l!Z-BB{;0sqBEPL_gO91y)cbwWS9MD%th9> z)s;{>t2&+;u+&MC!7$Z#q3@KeZM2zAt+#B4GwU14tE(Fi7}nv8Cdv-1B`p00V5B2q zWOM-O=mI*U2k4GIpf?79K1Z8?qfK~D03%L-xx3ngCvpH*uQtz)E1ik1mP%wCA6=`a z#~kw5dYGI|`^PG38?~~oP;V1n8Nsvxt&JvGblfIJnyO`(uTASgDX7kNx0pG%F&a$S z=b`nqXuqlmvQjYuUJJEAND+1b{t&eXuiFpBgcTuU>af4E5o1l)7{)M;Mz=v2(D_X0X8+O4;k|uL!S;TjjBDx$_G_vw zT}?c5s&?UMlDDuATN|sPn~I^I!&YNMJ-RuVg?cbp<(~4vV_z7v31g7p z(4w3&b~#k-ohD?A%bGEDfL}jFz&vMwd=%2gAo>YF1YDfZp*WMY}TbY}L`Ydg(X6Iu#gN>OVmvXvC6sES%pi$JIZ)K(lUq19$*lh|E*-I+Bg zE9aD6`2`hHa?G6{!0(t75~rTIRY>sOjGfp?U{>>H-p-qu_x&cX*8>9W!{ax*zrpNJ zM5dbs$mh`I0|1Ww%X?{SyY(bbhA5?MefRiTYasG&T724i zyq8M(;#38#Ue41@whGWmbFi=c%`EP1^Z4OB-iTNGq`ZkLY(`P1-zlP~xtZljoXLkU zF|@#f^)lUW_{v5_s@jwSrKuR)Jcg5(747?IKNr>yw6eoW=_p z)WpF70~YCsVLWK%uH=HJV$7lp^L{9kT%?zZi2))oKtu%rh65xUH_3;CEIluTqtE#O zXf)qG9eX(XU!>RMnUiZ=Ea(HpdpKA|GpHr;F@n?JGbXG~or9*9D6G$Ften@Dn_9jg z%c)*gV2?4`5u45w|DPkysX$;HoMTU1fq%E~KZba@cE*zN1sQGc8zr3SU=rv?4VG4e z@$74OP>A5160T|~&mZ{_P->m8(DM3!-#nuhRLN<4{tie14x@b;ixfMc1>>x+jCXVE z(1O_g;sB%8zE5D)#+4DoF2=8!b971}|0rOyubY1*!@&?YpfbLeg^b~SN8uCWexbusIU?@wrpn6FzHoq4S+Wo&BVNUw=r;mgyJ4F=L%WK0#2x&7&P26w3enem z0t6D>yGCugLVbFR&e4D&oMX$DOUs4nw4?XTmj5drGj1G+Uuihb6OjMW4otI2(z|2D`2aV<4Cl=X+3}J&35o09sHLVA< zUyo^>3$&Fntu_Vsfi|Bxw=#1sVB>S~W^>v!MTHxR%7`8X$55Z)tm;t>XzQjhAPy!D zw#xbsai{+ZZ5#4oSUTZ@aJ^aDYvD$-tgeOkn*CuGgpWc+*NwgDhNAa&L37alc+{9P zw#160?F)6WKNuFuGeNaJnQSQ66i^+JP(?9Gu8&7p91b`X6oF}4JBG3WkH=-`a>vjY zjWgkAuuo#X2xvfWLtjS6n1YD=bRMeh*hQvyZ#Ag!U~{926&kB$6saJJ;Mp;RG7_m; z6ulb8*?7f^BAzEvByJ$LHxXdU5VsMai;5-!e6CJ;v-WGOo&xg(Muo(h=@XjMOAv%|krZ=py?U5x$7o literal 0 HcmV?d00001 diff --git a/models/match.py b/models/match.py new file mode 100644 index 0000000..fc1cf0a --- /dev/null +++ b/models/match.py @@ -0,0 +1,27 @@ +from models.player import Player + +class Match: + """Get two players + + print a string with both ids + return a tuple of list player, score + """ + def __init__(self, player1, player2): + self.name = None + self.player1 = player1 + self.player2 = player2 + self.score1 = 0 + self.score2 = 0 + self.data = ([self.player1, self.score1], [self.player2, self.score2]) + + def __str__(self): + return f"[{self.player1}, {self.player2}]" #pretty print for prompt + + def __repr__(self): + #return ([self.player1, self.score1], [self.player2, self.score2]) + return str(self) + + def update(self): + """Update tuple when attributs have change""" + self.data = ([self.player1, self.score1], [self.player2, self.score2]) + return self.data diff --git a/models/participant.py b/models/participant.py new file mode 100644 index 0000000..7ac702c --- /dev/null +++ b/models/participant.py @@ -0,0 +1,49 @@ +from collections import UserDict +import json +from models.player import Player + + +class Participant(UserDict): + """Dict of players and score attending a tournament + + takes tournament's name and list of object Player + returns dict with player: score""" + def __init__(self, player_list = None): + #self.tournament + self.player_list = player_list + self.identifiant = () + self.data = {} + self.PLAYERS_FILE = "./data/players/player_list.json" + # initiate list + + + def create_participant_from_list(self, players): + for item in players: + self.data[item.chess_id] = 0 + return self.data + + def get_list_from_file(self): + with open(self.PLAYERS_FILE) as file: + self.data = json.load(file) + + + def get_players_from_file(self): + """create a Player list from the json file + + uses file in current folder + return a list of object Player + """ + players = [] + data = {} + with open(self.PLAYERS_FILE) as file: + data = json.load(file) + for i in data: + players.append( + Player(name=data[i][0], lastname=data[i][1], birthdate=data[i][2], gender=data[i][3], chess_id=i)) + # print(data[i][0]) + j = + 1 + return self.create_participant_from_list(players) + + def ask_for_new_participant(self): + pass + diff --git a/models/player.py b/models/player.py new file mode 100644 index 0000000..8091637 --- /dev/null +++ b/models/player.py @@ -0,0 +1,20 @@ +import json +from datetime import datetime + +class Player: + """Player from the club""" + def __init__(self, name, lastname, birthdate, gender, chess_id=None): + self.name = name + self.lastname = lastname + self.birthdate = birthdate + self.gender = gender + self.chess_id = chess_id + + def __str__(self): + """Used in print""" +# return f"{self.name} {self.lastname}, né le {self.birthdate}, genre: {self.gender}" + return self.chess_id + + def __repr__(self): + return str(self) + diff --git a/models/scorelist.py b/models/scorelist.py new file mode 100644 index 0000000..010935a --- /dev/null +++ b/models/scorelist.py @@ -0,0 +1,4 @@ + +class ScoreList(list): + """Player tuple (name, lastname) and score""" + def __init__(self): diff --git a/models/tournament.py b/models/tournament.py new file mode 100644 index 0000000..b104e23 --- /dev/null +++ b/models/tournament.py @@ -0,0 +1,31 @@ +from models.participant import Participant +from models.turn import Turn + + +class Tournament: + """A competition with players and turns + + takes player_list + """ + def __init__(self, + name, + participants, + location = "Club", + date_start = "today", + date_end = 'today', + current_turn = 1, + total_turn = 4 ): + self.name = name + self.participants = participants + self.location = location + self.date_start = date_start + self.date_end = date_end + self.total_turn = total_turn + self.current_turn = current_turn + self.description = "Pas encore de description" + self.turn_list = [] + + def run_turns(self): + pass + #if self.current_turn == "Round 1": + diff --git a/models/turn.py b/models/turn.py new file mode 100644 index 0000000..82acf53 --- /dev/null +++ b/models/turn.py @@ -0,0 +1,74 @@ +from random import choice, shuffle +from models.participant import Participant +from models.match import Match + +class Turn: + """Round for tournament + + has name, dict of participant (object) + """ + def __init__(self, participants, name="Round 1"): + self.name = name + self.participants = participants + self.match_history = [] + self.match_list = [] + self.match_result = [] + self.player_list = [] + + def create_player_list(self): #not used for now + """name list from dict""" + for player in self.participants: + self.player_list.append([player[0], player[1]]) + + def ramble_player_list(self): + """shuffle player's list""" + return shuffle(self.player_list) + + def sort_scores(self, player_list): + """order players on score""" + def score(couple): + return couple[1] + return sorted(player_list, key=score) + + def sort_players_by_score(self): + return sorted(self.participants.items(), key=lambda t: t[1]) + + + def create_match(self): + print("Liste des joueurs: ", self.player_list) + j = 0 + for i in range(0, len(self.player_list), 2): + j += 1 + match = Match(self.player_list[i][0], self.player_list[i+1][0]) + match.name = "match" + str(j) + + if match in self.match_history: # If match has already been made, choose the next player + match = Match(self.player_list[i][0], self.player_list[i+2][0]) + self.match_list.append(match) + else: + self.match_list.append(match) + #print(match) + + self.match_history.append([self.name, self.match_list]) + return self.match_list + # if i.index + + def input_scores(self): + for match in self.match_list: + print(match.name) + self.result = input(f"Vainqueur du {match.name} : 1.{match.player1}, 2.{match.player2}, 3.nul\n ? ") + if self.result == "1": + self.participants[match.player1] += 1 + match.score1 += 1 + if self.result == "2": + self.participants[match.player2] += 1 + match.score2 += 1 + if self.result == "3": + self.participants[match.player1] += 0.5 + match.score1 += 0.5 + self.participants[match.player2] += 0.5 + match.score2 += 0.5 + match.update() # update match then save it at the end of the turn + self.match_result.append(match.data) + return self.match_result + diff --git a/player_list.json b/player_list.json new file mode 100644 index 0000000..0eea98e --- /dev/null +++ b/player_list.json @@ -0,0 +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 diff --git a/tournoi/menu.py b/tournoi/menu.py deleted file mode 100644 index 38c347d..0000000 --- a/tournoi/menu.py +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index d64df1e..0000000 --- a/tournoi/player.py +++ /dev/null @@ -1,19 +0,0 @@ -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/views/__pycache__/base.cpython-310.pyc b/views/__pycache__/base.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e3003b64720922bdee7728f8d30ddb1c1cbb9f8a GIT binary patch literal 637 zcmZuuy-or_5Z=8XI0+PDVl1yEFH3IVT`Zj(C|AE18u_5Sy>L!>g!U?BK(1jHdZuLmZ zjv@a?EQmUw+6N;@L^+8pP9vLJ++LE%;SP7fySxJZ)xx<;#MAufM#))b{FzAeV}C4+ zA5UZw3msD!vlTp}c0siRh7*`U!xdT4!qH+nQuusnK2L**oQYr