Browse Source

piles de cartes visibles

master
bollet.c 11 months ago
parent
commit
9c774e99e9
  1. 35
      test_interface.py

35
test_interface.py

@ -5,12 +5,6 @@ from test_interaction import Jeux, vider_dans
from Pile import Pile_chaine as Pile
from File import File_chaine as File
pique = "๐Ÿ‚ก๐Ÿ‚ข๐Ÿ‚ฃ๐Ÿ‚ค๐Ÿ‚ฅ๐Ÿ‚ฆ๐Ÿ‚ง๐Ÿ‚จ๐Ÿ‚ฉ๐Ÿ‚ช๐Ÿ‚ซ๐Ÿ‚ฌ๐Ÿ‚ญ๐Ÿ‚ฎ"
coeur = "๐Ÿ‚ฑ๐Ÿ‚ฒ๐Ÿ‚ณ๐Ÿ‚ด๐Ÿ‚ต๐Ÿ‚ถ๐Ÿ‚ท๐Ÿ‚ธ๐Ÿ‚น๐Ÿ‚บ๐Ÿ‚ป๐Ÿ‚ผ๐Ÿ‚ฝ๐Ÿ‚พ"
carreau = "๐Ÿƒ๐Ÿƒ‚๐Ÿƒƒ๐Ÿƒ„๐Ÿƒ…๐Ÿƒ†๐Ÿƒ‡๐Ÿƒˆ๐Ÿƒ‰๐ŸƒŠ๐Ÿƒ‹๐ŸƒŒ๐Ÿƒ๐ŸƒŽ"
trefle = "๐Ÿƒ‘๐Ÿƒ’๐Ÿƒ“๐Ÿƒ”๐Ÿƒ•๐Ÿƒ–๐Ÿƒ—๐Ÿƒ˜๐Ÿƒ™๐Ÿƒš๐Ÿƒ›๐Ÿƒœ๐Ÿƒ๐Ÿƒž"
cartes = pique + coeur + carreau + trefle
class Interface(tk.Frame):
"""interface du jeu"""
def __init__(self, master):
@ -38,7 +32,7 @@ class Interface(tk.Frame):
self.C = tk.Canvas(self.menu, bg="black",height=500, width=728, highlightthickness=0)
self.C.grid(row=0)
for i in range(50):
self.C.create_text(randint(0,728),randint(0,500),fill="white",font="Times 20",text=choice(cartes))
self.C.create_text(randint(0,728),randint(0,500),fill="white",font="Times 20",text=choice("๐Ÿ‚ก๐Ÿ‚ข๐Ÿ‚ฃ๐Ÿ‚ค๐Ÿ‚ฅ๐Ÿ‚ฆ๐Ÿ‚ง๐Ÿ‚จ๐Ÿ‚ฉ๐Ÿ‚ช๐Ÿ‚ซ๐Ÿ‚ฌ๐Ÿ‚ญ๐Ÿ‚ฎ๐Ÿ‚ฑ๐Ÿ‚ฒ๐Ÿ‚ณ๐Ÿ‚ด๐Ÿ‚ต๐Ÿ‚ถ๐Ÿ‚ท๐Ÿ‚ธ๐Ÿ‚น๐Ÿ‚บ๐Ÿ‚ป๐Ÿ‚ผ๐Ÿ‚ฝ๐Ÿ‚พ๐Ÿƒ๐Ÿƒ‚๐Ÿƒƒ๐Ÿƒ„๐Ÿƒ…๐Ÿƒ†๐Ÿƒ‡๐Ÿƒˆ๐Ÿƒ‰๐ŸƒŠ๐Ÿƒ‹๐ŸƒŒ๐Ÿƒ๐ŸƒŽ๐Ÿƒ‘๐Ÿƒ’๐Ÿƒ“๐Ÿƒ”๐Ÿƒ•๐Ÿƒ–๐Ÿƒ—๐Ÿƒ˜๐Ÿƒ™๐Ÿƒš๐Ÿƒ›๐Ÿƒœ๐Ÿƒ๐Ÿƒž"))
titre = tk.Label(self.menu, text="Bataille",bg="black", fg="white",font=("eufm10", 42),anchor ="n")
titre.grid(sticky="N", row=0, pady=(100, 0))
@ -56,7 +50,7 @@ class Interface(tk.Frame):
"""affiche un fond aleatoire different"""
self.C.delete("all")
for i in range(50):
self.C.create_text(randint(0,728),randint(0,500),fill="white",font="Times 20",text=choice(cartes))
self.C.create_text(randint(0,728),randint(0,500),fill="white",font="Times 20",text=choice("๐Ÿ‚ก๐Ÿ‚ข๐Ÿ‚ฃ๐Ÿ‚ค๐Ÿ‚ฅ๐Ÿ‚ฆ๐Ÿ‚ง๐Ÿ‚จ๐Ÿ‚ฉ๐Ÿ‚ช๐Ÿ‚ซ๐Ÿ‚ฌ๐Ÿ‚ญ๐Ÿ‚ฎ๐Ÿ‚ฑ๐Ÿ‚ฒ๐Ÿ‚ณ๐Ÿ‚ด๐Ÿ‚ต๐Ÿ‚ถ๐Ÿ‚ท๐Ÿ‚ธ๐Ÿ‚น๐Ÿ‚บ๐Ÿ‚ป๐Ÿ‚ผ๐Ÿ‚ฝ๐Ÿ‚พ๐Ÿƒ๐Ÿƒ‚๐Ÿƒƒ๐Ÿƒ„๐Ÿƒ…๐Ÿƒ†๐Ÿƒ‡๐Ÿƒˆ๐Ÿƒ‰๐ŸƒŠ๐Ÿƒ‹๐ŸƒŒ๐Ÿƒ๐ŸƒŽ๐Ÿƒ‘๐Ÿƒ’๐Ÿƒ“๐Ÿƒ”๐Ÿƒ•๐Ÿƒ–๐Ÿƒ—๐Ÿƒ˜๐Ÿƒ™๐Ÿƒš๐Ÿƒ›๐Ÿƒœ๐Ÿƒ๐Ÿƒž"))
def jouer(self):
"""interface de jeu"""
@ -65,7 +59,7 @@ class Interface(tk.Frame):
self.jeu = tk.Frame()
self.jeu.grid()
jeu = Jeux(16)
jeu = Jeux(6)
(self.paquet_joueur, self.paquet_ordi) = jeu.distribue()
self.mise_joueur = Pile()
self.mise_ordi = Pile()
@ -76,7 +70,7 @@ class Interface(tk.Frame):
self.etat = tk.Label(self.jeu, text="",bg="white", fg="black",font=("arial", 20))
self.etat.grid(sticky="",row=0,column=0)
self.canvas_joueur = tk.Canvas(self.frame_principale, bg="black",height=463, width=30, highlightthickness=0)
self.canvas_joueur = tk.Canvas(self.frame_principale, bg="green",height=463, width=30, highlightthickness=0)
self.canvas_joueur.grid(row=1,column=0)
@ -111,7 +105,7 @@ class Interface(tk.Frame):
self.carte_restantes2.grid(row=3, padx=(10, 10))
self.ordi.grid(row=1,column=3)
self.canvas_ordi = tk.Canvas(self.frame_principale, bg="black",height=463, width=30, highlightthickness=0)
self.canvas_ordi = tk.Canvas(self.frame_principale, bg="red",height=463, width=30, highlightthickness=0)
self.canvas_ordi.grid(row=1,column=4)
def affiche_top_carte(self):
@ -127,16 +121,17 @@ class Interface(tk.Frame):
def update_canvas(self,canvas, paquet):
"""met ร  jour les cartes affichรฉes du paquet"""
#juste cartes `blank`seraient meilleures, non ?
canvas.delete("all")
tmp = File()
i=0
while not paquet.est_vide():
tmp_valeur = paquet.defiler()
tmp.enfiler(tmp_valeur)
canvas.create_text(15,30*i-10,fill="white",font="Times 20",text=tmp_valeur)
i+=1
while not tmp.est_vide():
paquet.enfiler(tmp.defiler())
for i in range(paquet.taille() - 1):
lettre = canvas.create_text(13,433-10*i,fill="black",font="Times 30",text="๐Ÿ‚ ")
r=canvas.create_rectangle(canvas.bbox(lettre),fill="white")
canvas.tag_lower(r,lettre)
lettre = canvas.create_text(13,433-10*(paquet.taille()-1),fill="black",font="Times 30",text=paquet.tete())
r=canvas.create_rectangle(canvas.bbox(lettre),fill="white")
canvas.tag_lower(r,lettre)
def carte_suivante(self):
"""mรฉthode principale : rรฉalise une manche"""

Loadingโ€ฆ
Cancel
Save