From 54bd78adf1578dfe29a79ba7914be29876f72c87 Mon Sep 17 00:00:00 2001 From: "loic.delpui" Date: Mon, 11 Dec 2023 15:34:52 +0100 Subject: [PATCH] uwu --- projet bataille.py | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 projet bataille.py diff --git a/projet bataille.py b/projet bataille.py new file mode 100644 index 0000000..d2600b8 --- /dev/null +++ b/projet bataille.py @@ -0,0 +1,47 @@ +from tkinter import * +from File import * +from random import shuffle + +class Carte: + def __init__(self, valeur, couleur): + self.valeur = valeur + self.couleur = couleur + def compare(self, other): + if self.valeur > other.valeur: + return 1 + elif self.valeur < other.valeur: + return -1 + return 0 + +class Jeux: + def __init__ (self, nbr_cartes): + #self.window = Tk() + self.nb = nbr_cartes + if self.nb != 32 and self.nb != 52: + raise ValueError("Choisissez 32 ou 52 cartes") + self.paquet = [] + for i in couleurs: + if self.nb == 52: + for j in numeros: + self.paquet.append(Carte(j, i)) + else: + for j in numeros[5:]: + self.paquet.append(Carte(j, i)) + shuffle(self.paquet) + + def distribue(self): + while len(self.paquet) > 0: + for player in players: + player.enfiler(self.paquet.pop(0)) + +couleurs = ["Coeur", "Pique", "Carreaux", "Trèfle"] +numeros = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] + +jeu = Jeux(52) + +players = [File_chaine(), File_chaine()] + +jeu.distribue() + +while not (players[0].est_vide() or players[1].est_vide()): + players[0].compare(players[1]) \ No newline at end of file