You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
from random import *
|
|
from lib.File import File_lst as File
|
|
|
|
class Carte:
|
|
"""
|
|
Classe représentant une 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)
|
|
"""
|
|
def __init__(self, valeur, couleur):
|
|
self.valeur = valeur
|
|
self.couleur = couleur
|
|
|
|
def compare(self, other):
|
|
if self.valeur > other:
|
|
return 1
|
|
elif self.valeur < other:
|
|
return -1
|
|
else:
|
|
return 0
|
|
|
|
|
|
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)
|
|
else:
|
|
pq = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
|
|
|
|
|
|
def distribue(self):
|
|
cp = self.paquet
|
|
f1 = File()
|
|
f2 = File()
|
|
while not cp.est_vide():
|
|
f1.enfiler(cp.defiler())
|
|
f2.enfiler(cp.defiler())
|
|
return f1, f2
|
|
|
|
|
|
class Joueur:
|
|
def __init__(self, paquet_j, nom):
|
|
self.paquet_j = paquet_j
|
|
self.nom = nom
|
|
|
|
def tire_carte(self):
|
|
self.derniere_carte = self.paquet_j.defiler()
|
|
return self.derniere_carte
|
|
|