-
Notifications
You must be signed in to change notification settings - Fork 4
/
shoe.py
38 lines (32 loc) · 1.16 KB
/
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
33
34
35
36
37
38
from card import Card, Suit
import random
class Shoe:
def __init__(self, numDecks, isVerbose):
assert numDecks >= 1
self.numDecks = numDecks
self.isVerbose = isVerbose
self.discard = []
self.drawPile = []
for deck in range(0, numDecks):
for suit in Suit.Clubs, Suit.Diamonds, Suit.Hearts, Suit.Spades:
for rank in range (1, 14):
self.drawPile.append(Card(rank, suit))
def discardCard(self, card):
self.discard.append(card)
def drawCard(self):
return self.drawPile.pop(0)
def getDecksRemaining(self):
penetration = self.getPenetration()
decksRemaining = (1 - penetration) * self.numDecks
return round(decksRemaining * 2) / 2
def getPenetration(self):
return len(self.discard) / (self.numDecks * 52)
def printDeck(self):
for card in self.drawPile:
card.printCard()
def resetShoe(self):
if self.isVerbose: print("Resetting shoe...")
for card in self.discard:
self.drawPile.append(card)
self.discard = []
random.shuffle(self.drawPile)