|
|
@ -6,6 +6,9 @@ from File import File_chaine as File |
|
|
|
#______________________________________ |
|
|
|
class Carte: |
|
|
|
def __init__(self, valeur, couleur): |
|
|
|
str(valeur) |
|
|
|
str(couleur) |
|
|
|
|
|
|
|
self.valeur = valeur |
|
|
|
self.couleur = couleur |
|
|
|
|
|
|
@ -18,32 +21,35 @@ class Carte: |
|
|
|
return -1 |
|
|
|
return 0 |
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
if self.valeur <= 10: |
|
|
|
tmp = str(self.valeur) |
|
|
|
else: |
|
|
|
tmp = ["Valet","Dame","Roi"][self.valeur-11] |
|
|
|
|
|
|
|
return tmp + " de " + self.couleur |
|
|
|
#__________ |
|
|
|
class Jeux: |
|
|
|
def __init__(self): |
|
|
|
self.paquet = [] |
|
|
|
couleurs = ["Coeurs", "Carreaux", "Trèfles", "Piques"] |
|
|
|
couleurs = ["Coeur", "Carreaux", "Trèfle", "Pique"] |
|
|
|
if nb_cartes == 32: |
|
|
|
valeurs = ["1", "7", "8", "9", "10", "Valet", "Dame", "Roi", "As"] |
|
|
|
valeurs = [1, 7, 8, 9, 10, 11, 12, 13] |
|
|
|
elif nb_cartes == 52: |
|
|
|
valeurs = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Valet", "Dame", "Roi", "As"] |
|
|
|
valeurs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] |
|
|
|
else: |
|
|
|
print("Nombre de cartes invalide") |
|
|
|
time.sleep(0.5) |
|
|
|
raise ValueError |
|
|
|
raise ValueError("Nombre de cartes invalide") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for couleur in couleurs: |
|
|
|
for valeur in valeurs: |
|
|
|
paquet = [Carte(valeur, couleur)] |
|
|
|
shuffle(paquet) |
|
|
|
|
|
|
|
for carte in paquet: |
|
|
|
print(carte) |
|
|
|
self.paquet.append(Carte(valeur, couleur)) |
|
|
|
shuffle(self.paquet) |
|
|
|
print(self.paquet) |
|
|
|
distribute() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#________ |
|
|
|
|
|
|
|
|
|
|
|
def distribute(self): |
|
|
|
f1 = File_lst() |
|
|
@ -54,5 +60,85 @@ class Jeux: |
|
|
|
return f1, f2 |
|
|
|
|
|
|
|
#______________________________________ |
|
|
|
nb_cartes = 32 #52 |
|
|
|
nb_cartes = 42 #52 |
|
|
|
Jeux() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#result = compare() |
|
|
|
#if result == -1: |
|
|
|
|
|
|
|
#if result == 1: |
|
|
|
|
|
|
|
|
|
|
|
#if result == 0: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#______________________________________ |
|
|
|
|
|
|
|
#if f1.est_vide: |
|
|
|
#print(f"victoire du joueur 1") |
|
|
|
|
|
|
|
#elif f2.est_vide: |
|
|
|
#print(f"victoire du joueur 2") |
|
|
|
|
|
|
|