forked from tiyd-python-2015-01/blackjack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshoe.py
32 lines (22 loc) · 815 Bytes
/
shoe.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
"""Shoe class"""
"""Shoe collaborates with Card and Hand"""
"""It is responsible for receiving cards from Card, compiling and
shuffling the decks, and dealing to the Hand"""
from card import Card, ranks, suits
import random
class Shoe:
"""Collects decks. Shuffles. Deals cards to hands"""
def __init__(self, how_many=1):
self.deck = [Card(rank, suit)
for rank in ranks
for suit in suits]
def __str__(self):
return "Shoe contains {} cards.".format(len(self.deck))
def shuffle_shoe(self):
"""Shuffles the deck"""
random.shuffle(self.deck)
return self.deck
def deal_card(self):
"""Deals a card"""
dealt_card = self.deck.pop(random.randrange(0, len(self.deck)))
return dealt_card