|
|
|
@ -10,7 +10,7 @@ class Carte: |
|
|
|
def compare(self, other): |
|
|
|
if self.valeur > other.valeur : |
|
|
|
return 1 |
|
|
|
elif self.valeur > other.valeur : |
|
|
|
elif self.valeur < other.valeur : |
|
|
|
return -1 |
|
|
|
elif self.valeur == other.valeur : |
|
|
|
return 0 |
|
|
|
@ -21,13 +21,19 @@ class Carte: |
|
|
|
|
|
|
|
|
|
|
|
class Jeux: |
|
|
|
def __init__(self): |
|
|
|
valeurs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] |
|
|
|
def __init__(self, nbmax = 52): |
|
|
|
i = 0 |
|
|
|
valeurs = [1, 8, 9, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7] |
|
|
|
couleurs = ["coeur", "pique", "carreau", "trefle"] |
|
|
|
jeu = [] |
|
|
|
for coul in couleurs: |
|
|
|
for val in valeurs: |
|
|
|
for val in valeurs: |
|
|
|
if i >= nbmax: |
|
|
|
break |
|
|
|
for coul in couleurs: |
|
|
|
jeu.append(Carte(val, coul)) |
|
|
|
i += 1 |
|
|
|
|
|
|
|
|
|
|
|
random.shuffle(jeu) |
|
|
|
self.paquet = jeu |
|
|
|
def distribue(self): |
|
|
|
@ -41,6 +47,7 @@ class Jeux: |
|
|
|
i += 1 |
|
|
|
return jeu1, jeu2 |
|
|
|
|
|
|
|
""" |
|
|
|
def partie(jeu1, jeu2): |
|
|
|
while not jeu1.est_vide() and not jeu2.est_vide(): |
|
|
|
c1 = jeu1.defiler() |
|
|
|
@ -65,14 +72,21 @@ def partie(jeu1, jeu2): |
|
|
|
elif resultat == -1 : |
|
|
|
while not gain.est_vide(): |
|
|
|
jeu2.enfiler(gain.defiler()) |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" |
|
|
|
def partie_TeSt(j1, j2): |
|
|
|
while not (j1.est_vide() or j2.est_vide()): |
|
|
|
winner = "UwU" |
|
|
|
Round = 1 |
|
|
|
while not (j1.est_vide() or j2.est_vide() or winner == "égalité"): |
|
|
|
print(Round) |
|
|
|
Round += 1 |
|
|
|
|
|
|
|
c1 = j1.defiler() |
|
|
|
c2 = j2.defiler() |
|
|
|
|
|
|
|
|
|
|
|
gain = File() |
|
|
|
gain.enfiler(c1) |
|
|
|
gain.enfiler(c2) |
|
|
|
@ -82,15 +96,35 @@ def partie_TeSt(j1, j2): |
|
|
|
gain.enfiler(j2.defiler()) |
|
|
|
c1 = j1.defiler() |
|
|
|
c2 = j2.defiler() |
|
|
|
gain.enfiler(c1) |
|
|
|
gain.enfiler(c2) |
|
|
|
if random.randint(1, 2) == 1: |
|
|
|
gain.enfiler(c2) |
|
|
|
gain.enfiler(c1) |
|
|
|
else: |
|
|
|
gain.enfiler(c1) |
|
|
|
gain.enfiler(c2) |
|
|
|
resultat = c1.compare(c2) |
|
|
|
if resultat == 1: |
|
|
|
winner = "c j1 ki a ganier" |
|
|
|
|
|
|
|
while not gain.est_vide(): |
|
|
|
j1.enfiler(gain.defiler()) |
|
|
|
elif resultat == -1: |
|
|
|
winner = "c j2 ki a ganier" |
|
|
|
|
|
|
|
while not gain.est_vide(): |
|
|
|
j2.enfiler(gain.defiler()) |
|
|
|
else: |
|
|
|
|
|
|
|
""" |
|
|
|
if j1.taille() < 2 and not j2.taille() < 2: |
|
|
|
winner = "c j2 ki a ganier" |
|
|
|
elif not j1.taille() < 2 and j2.taille() < 2: |
|
|
|
winner = "c j2 ki a ganier" |
|
|
|
else: |
|
|
|
winner = "égalité" |
|
|
|
break |
|
|
|
print(j1, j2) |
|
|
|
return winner |
|
|
|
|
|
|
|
|
|
|
|
jeu = Jeux(8) |
|
|
|
j1, j2 = jeu.distribue() |
|
|
|
print(partie_TeSt(j1, j2)) |