From b87f611dfe3c9f8e6dbb9ed1861e26e09d319266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DELPUI=20Lo=C3=AFc?= Date: Fri, 15 Dec 2023 15:10:12 +0100 Subject: [PATCH] =?UTF-8?q?Transf=C3=A9rer=20les=20fichiers=20vers=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mon quoicoubébou Uwu --- projet bataille.py | 69 +++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/projet bataille.py b/projet bataille.py index 0b96289..31a4635 100644 --- a/projet bataille.py +++ b/projet bataille.py @@ -34,7 +34,33 @@ class Jeux: player.enfiler(self.paquet.pop(0)) def click(event): - print("ok") + x, y = event.x, event.y + if x > 50 and x < 150 and y > 100 and y < 250: + cartes_tour = [] + cartes_tour.extend([players[0].defiler(), players[1].defiler()]) + winner = cartes_tour[-2].compare(cartes_tour[-1]) + if winner == 2: + pass + else: + for carte in cartes_tour: + players[winner].enfiler(carte) + for i in range(2): + canvas.itemconfig(player_carte[i], text = cartes_tour[i].valeur + cartes_tour[i].couleur) + canvas.itemconfig(player_left[i], text = "Left : " + str(players[i].taille())) + if cartes_tour[i].couleur in ["♥", "♦"]: + canvas.itemconfig(player_carte[i], fill = "#f00") + else: + canvas.itemconfig(player_carte[i], fill = "#000") + + +couleurs = ["♥", "♦", "♣", "♠"] +numeros = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "R", "S"] + +jeu = Jeux(52) + +players = [File_chaine(), File_chaine()] + +jeu.distribue() window = Tk() window.title("Bataille") @@ -43,41 +69,14 @@ window.geometry(f"700x400+300+200") canvas = Canvas(window, width = 650, height = 300, background = "#fff") canvas.place(x = 25, y = 50) -player1_pack = canvas.create_rectangle(50, 100, 150, 250, fill = "#f77") -player1_carte = canvas.create_rectangle(200, 75, 300, 225, fill = "#fff") +canvas.create_rectangle(50, 100, 150, 250, fill = "#f77") +canvas.create_rectangle(200, 75, 300, 225, fill = "#fff") +canvas.create_rectangle(500, 100, 600, 250, fill = "#f77") +canvas.create_rectangle(350, 75, 450, 225, fill = "#fff") -player2_pack = canvas.create_rectangle(500, 100, 600, 250, fill = "#f77") -player2_carte = canvas.create_rectangle(350, 75, 450, 225, fill = "#fff") +player_left = [canvas.create_text(100, 175, text = "Left : " + str(players[0].taille())), canvas.create_text(550, 175, text = "Left : " + str(players[1].taille()))] +player_carte = [canvas.create_text(250, 150, text = "", font = ("Courrier New", 30, "bold")), canvas.create_text(400, 150, text = "", font = ("Courrier New", 30, "bold"))] canvas.bind("