29 lines
642 B
Python
29 lines
642 B
Python
import random
|
|
from collections import deque
|
|
|
|
from card import Card
|
|
|
|
|
|
class Deck:
|
|
def __init__(self):
|
|
self.deck = deque()
|
|
|
|
def generate_deck(self):
|
|
for suit in range(4):
|
|
if suit in [0, 2]:
|
|
for i in range(1, 14):
|
|
c = Card(i, suit)
|
|
self.deck.append(c)
|
|
elif suit in [1, 3]:
|
|
for i in range(2, 11):
|
|
c = Card(i, suit)
|
|
self.deck.append(c)
|
|
|
|
|
|
def shuffle(self):
|
|
random.shuffle(self.deck)
|
|
|
|
def draw(self):
|
|
if len(self.deck) > 0:
|
|
return self.deck.popleft()
|
|
|