|
|
@ -1,4 +1,4 @@ |
|
|
|
from random import * |
|
|
|
from random import randint |
|
|
|
from lib.File import File_lst as File |
|
|
|
|
|
|
|
class Carte: |
|
|
@ -7,16 +7,26 @@ class Carte: |
|
|
|
|
|
|
|
Arguments: |
|
|
|
valeur: int -- Valeur allant de 2 à 14 (Valet=11, Dame=12, Roi=13, As=14) |
|
|
|
couleur: int -- Allant de 0 à 3 (Carreau, Coeur, Pique, Trefle) |
|
|
|
couleur: int -- Allant de 0 à 3 (0: Carreau, 1: Coeur, 2: Pique, 3: Trefle) |
|
|
|
""" |
|
|
|
|
|
|
|
CARREAU = 0 |
|
|
|
COEUR = 1 |
|
|
|
PIQUE = 2 |
|
|
|
TREFLE = 3 |
|
|
|
VALET = 11 |
|
|
|
DAME = 12 |
|
|
|
ROI = 13 |
|
|
|
AS = 14 |
|
|
|
|
|
|
|
def __init__(self, valeur, couleur): |
|
|
|
self.valeur = valeur |
|
|
|
self.couleur = couleur |
|
|
|
|
|
|
|
def compare(self, other): |
|
|
|
if self.valeur > other: |
|
|
|
if self.valeur > other.valeur: |
|
|
|
return 1 |
|
|
|
elif self.valeur < other: |
|
|
|
elif self.valeur < other.valeur: |
|
|
|
return -1 |
|
|
|
else: |
|
|
|
return 0 |
|
|
@ -26,18 +36,17 @@ class Jeux: |
|
|
|
def __init__(self, nbcartes): |
|
|
|
self.paquet = File() |
|
|
|
self.couleur = File() |
|
|
|
#Cartes 1 à 10 et 11 pour Valet, 12 pour Dame et 13 pour Roi et 14 pour As |
|
|
|
if nbcartes == 32: |
|
|
|
for i in range(4): |
|
|
|
crt = [7, 8, 9, 10, 11, 12, 13, 14] |
|
|
|
couleur = [0, 1, 2, 3] |
|
|
|
for val in range(len(crt)): |
|
|
|
rd = randint(0, len(crt)-1) |
|
|
|
self.paquet.enfiler(crt[rd]) |
|
|
|
self.couleur.enfiler(couleur[i]) |
|
|
|
crt.pop(rd) |
|
|
|
for couleur in [Carte.CARREAU, Carte.COEUR, Carte.PIQUE, Carte.TREFLE]: |
|
|
|
valeurs = [7, 8, 9, 10, Carte.VALET, Carte.DAME, Carte.ROI, Carte.AS] |
|
|
|
for i in range(8): |
|
|
|
rand = randint(0, len(valeurs)-1) |
|
|
|
carte = Carte(valeurs.pop(rand), couleur) |
|
|
|
self.paquet.enfiler(carte) |
|
|
|
#self.couleur.enfiler(couleur) |
|
|
|
#valeurs.pop(rand) |
|
|
|
else: |
|
|
|
pq = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] |
|
|
|
pq = [2, 3, 4, 5, 6, 7, 8, 9, 10, Carte.VALET, Carte.DAME, Carte.ROI, Carte.AS] |
|
|
|
|
|
|
|
|
|
|
|
def distribue(self): |
|
|
@ -51,10 +60,11 @@ class Jeux: |
|
|
|
|
|
|
|
|
|
|
|
class Joueur: |
|
|
|
def __init__(self, paquet_j, nom): |
|
|
|
self.paquet_j = paquet_j |
|
|
|
def __init__(self, paquet, nom): |
|
|
|
self.paquet = paquet |
|
|
|
self.nom = nom |
|
|
|
self.derniere_carte = None |
|
|
|
|
|
|
|
def tire_carte(self): |
|
|
|
self.derniere_carte = self.paquet_j.defiler() |
|
|
|
self.derniere_carte = self.paquet.defiler() |
|
|
|
return self.derniere_carte |
|
|
|