|
@ -34,50 +34,49 @@ class Jeux: |
|
|
player.enfiler(self.paquet.pop(0)) |
|
|
player.enfiler(self.paquet.pop(0)) |
|
|
|
|
|
|
|
|
def click(event): |
|
|
def click(event): |
|
|
print("ok") |
|
|
x, y = event.x, event.y |
|
|
|
|
|
if x > 50 and x < 150 and y > 100 and y < 250: |
|
|
window = Tk() |
|
|
cartes_tour = [] |
|
|
window.title("Bataille") |
|
|
cartes_tour.extend([players[0].defiler(), players[1].defiler()]) |
|
|
window.geometry(f"700x400+300+200") |
|
|
winner = cartes_tour[-2].compare(cartes_tour[-1]) |
|
|
|
|
|
if winner == 2: |
|
|
canvas = Canvas(window, width = 650, height = 300, background = "#fff") |
|
|
pass |
|
|
canvas.place(x = 25, y = 50) |
|
|
else: |
|
|
|
|
|
for carte in cartes_tour: |
|
|
player1_pack = canvas.create_rectangle(50, 100, 150, 250, fill = "#f77") |
|
|
players[winner].enfiler(carte) |
|
|
player1_carte = canvas.create_rectangle(200, 75, 300, 225, fill = "#fff") |
|
|
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") |
|
|
|
|
|
|
|
|
player2_pack = canvas.create_rectangle(500, 100, 600, 250, fill = "#f77") |
|
|
|
|
|
player2_carte = canvas.create_rectangle(350, 75, 450, 225, fill = "#fff") |
|
|
|
|
|
|
|
|
|
|
|
canvas.bind("<Button 1>", click) |
|
|
couleurs = ["♥", "♦", "♣", "♠"] |
|
|
couleurs = ["Coeur", "Pique", "Carreaux", "Trèfle"] |
|
|
numeros = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "R", "S"] |
|
|
numeros = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
|
|
|
|
|
|
|
|
|
|
|
jeu = Jeux(52) |
|
|
jeu = Jeux(52) |
|
|
|
|
|
|
|
|
players = [File_chaine(), File_chaine()] |
|
|
players = [File_chaine(), File_chaine()] |
|
|
next_game = [[], []] |
|
|
|
|
|
|
|
|
|
|
|
jeu.distribue() |
|
|
jeu.distribue() |
|
|
|
|
|
|
|
|
while not (players[0].est_vide() and len(next_game[0])!=0 or players[1].est_vide() and len(next_game[1])!=0): |
|
|
window = Tk() |
|
|
cartes_tour = [] |
|
|
window.title("Bataille") |
|
|
cartes_tour.extend([players[0].defiler(), players[1].defiler()]) |
|
|
window.geometry(f"700x400+300+200") |
|
|
winner = cartes_tour[-2].compare(cartes_tour[-1]) |
|
|
|
|
|
if winner == 2: |
|
|
|
|
|
pass |
|
|
|
|
|
else: |
|
|
|
|
|
next_game[winner].extend(cartes_tour) |
|
|
|
|
|
for player_id in range(2): |
|
|
|
|
|
if players[player_id].est_vide() and len(next_game[player_id])==0: |
|
|
|
|
|
shuffle(next_game[player_id]) |
|
|
|
|
|
for i in next_game[player_id]: |
|
|
|
|
|
players[player_id].enfiler(i) |
|
|
|
|
|
next_game[player_id] = [] |
|
|
|
|
|
|
|
|
|
|
|
if players[0].est_vide(): |
|
|
canvas = Canvas(window, width = 650, height = 300, background = "#fff") |
|
|
print("Le joueur 1 a perdu", players[0].taille(), players[1].taille()) |
|
|
canvas.place(x = 25, y = 50) |
|
|
elif players[1].est_vide(): |
|
|
|
|
|
print("Le joueur 2 a perdu") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
|
|
|
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("<Button 1>", click) |
|
|
|
|
|
|
|
|
|
|
|
window.mainloop() |