You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.7 KiB

2 years ago
from File import File_chaine
import tkinter as tk
from urllib.request import urlopen
import PIL
2 years ago
class Carte:
def __init__(self,valeur, couleur):
self.valeur = valeur
self.couleur = couleur
def compare(self, other):
self.other = other.valeur
if self.valeur > self.other :
return 1
elif self.valeur < self.other :
return -1
elif self.valeur == self.other :
return 0
return None
2 years ago
class Jeux:
def __init__(self, nb):
paquet = []
nb = len(self.paquet)
if nb == 32 :
nbcarte = nb
elif nb == 52 :
2 years ago
nbcarte = nb
else :
raise ValueError("Saissisez 32 ou 52 cartes")
2 years ago
for i in range(nbcarte):
carte = Carte()
paquet = []
def distribute(self, joueur):
for i in range(nbcarte):
mcarte1 = paquet - 1 #enlever moitie val
mcarte2 = paquet # le reste du paquet
if joueur == j1 :
return File_chaine(mcarte1)
elif joueur == j2 :
return File_chaine(mcarte2)
def jeu(self):
j1 = distribute(1)
j2 = distribute(2)
while not j1.estvide() or j2.estvide() :
#j1tete = j1.tete()
#j2tete = j2.tete()
2 years ago
while not Carte(j1.tete, j2.tete) == 0 :
2 years ago
carte_envers = #id carte à l'envers dans la base de donnée
j1.emfiler(carte_envers)#add carte à l'envers à j1
j2.emfiler(carte_envers)#add carte à l'envers à j2
j1.emfiler(j1.defiler())
j2.emfiler(j2.defiler())
2 years ago
if Carte(j1.tete, j2.tete) == 1 :
j1.enfiler(j1.defiler())
j1.enfiler(j2.defiler())
2 years ago
elif Carte(j1.tete, j2.tete) == -1 :
j2.enfiler(j1.defiler())
j2.enfiler(j2.defiler())
2 years ago
j1.defiler()
j2.defiler()
2 years ago
if j1.estvide() == True :
# j1 a perdu
else:
# j2 a perdu
class Gui:
def __init__(self) -> None:
self.win = tk.Tk()
src = 'http://www.iro.umontreal.ca/~reid/ift1146/E06/classic-cards/1.png'
url = urlopen(src)
raw_data = url.read()
print(raw_data)
url.close()
b64_data = encodestring(raw_data)
print(b64_data)
image = tk.PhotoImage(b64_data)
self.can = tk.Canvas(self.win, width=320, height=320)
self.can.create_image(200, 200, image=image)
self.can.pack()
self.win.mainloop()
Gui()