|
|
|
from util.bataille import Jeux, Joueur
|
|
|
|
from lib.Pile import Pile_lst as Pile
|
|
|
|
from util.window import Window
|
|
|
|
|
|
|
|
pile_j1 = Pile()
|
|
|
|
pile_j2 = Pile()
|
|
|
|
|
|
|
|
def jouer_tour(window):
|
|
|
|
if not window.p1.paquet.est_vide() and not window.p2.paquet.est_vide():
|
|
|
|
pile_j1.empiler(window.p1.tire_carte())
|
|
|
|
pile_j2.empiler(window.p2.tire_carte())
|
|
|
|
window.show_cards()
|
|
|
|
|
|
|
|
gagne = pile_j1.sommet().compare(pile_j2.sommet())
|
|
|
|
if gagne == 1:
|
|
|
|
j = window.p1
|
|
|
|
|
|
|
|
elif gagne == -1:
|
|
|
|
j = window.p2
|
|
|
|
|
|
|
|
else:
|
|
|
|
if not window.p1.paquet.est_vide() and not window.p2.paquet.est_vide():
|
|
|
|
pile_j1.empiler(window.p1.tire_carte())
|
|
|
|
pile_j2.empiler(window.p2.tire_carte())
|
|
|
|
else:
|
|
|
|
if window.p1.paquet.est_vide():
|
|
|
|
window.text_content.set("Vous avez perdu")
|
|
|
|
elif window.p2.paquet.est_vide():
|
|
|
|
window.text_content.set("L'ordinateur à perdu")
|
|
|
|
|
|
|
|
if gagne == 1 or gagne == -1:
|
|
|
|
while not pile_j1.est_vide() and not pile_j2.est_vide():
|
|
|
|
j.paquet.enfiler(pile_j1.depiler())
|
|
|
|
j.paquet.enfiler(pile_j2.depiler())
|
|
|
|
|
|
|
|
else:
|
|
|
|
if window.p1.paquet.est_vide() and window.p2.paquet.est_vide():
|
|
|
|
window.text_content.set("Partie nulle")
|
|
|
|
elif window.p1.paquet.est_vide():
|
|
|
|
window.text_content.set("Vous avez perdu")
|
|
|
|
elif window.p2.paquet.est_vide():
|
|
|
|
window.text_content.set("L'ordinateur à perdu")
|
|
|
|
|
|
|
|
#jeux = Jeux(32)
|
|
|
|
|
|
|
|
window = Window(jouer_tour)
|
|
|
|
window.build_pregame()
|
|
|
|
window.mainloop()
|