-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathccartas.py
43 lines (30 loc) · 1.06 KB
/
ccartas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import random
class Baraja():
palos = ('o', 'c', 'e', 'b')
cartas = ('A', '2', '3', '4', '5', '6', '7', 's', 'c', 'r')
def __init__(self):
self.__crea_baraja()
def __crea_baraja(self):
self.naipes = []
self.mano = []
for palo in self.palos:
for carta in self.cartas:
naipe = carta + palo
self.naipes.append(naipe)
def mezclar(self):
br = []
while len(self.naipes) != len(br):
n = random.randint(0, len(self.naipes)-1)
while self.naipes[n] in br:
n = random.randint(0, len(self.naipes)-1)
br.append(self.naipes[n])
self.naipes[:] = br
def repartir(self, players, cards):
for p in range(players):
self.mano.append([])
for ic in range(cards):
for ij in range(players):
carta = self.naipes.pop(0)
self.mano[ij].append(carta)
def recoger(self):
self.__crea_baraja()