-
Notifications
You must be signed in to change notification settings - Fork 1
/
dealer.py
53 lines (44 loc) · 1.2 KB
/
dealer.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
44
45
46
47
48
49
50
51
52
53
from deck import Deck, Card
import bisect
class Dealer:
def __init__(self):
self.deck_ = Deck()
self.deck_.shuffle()
self.communitycards_ = []
def deal_pockets(self, player_count=1):
# Pocket cards (later they'll belong to one of the players)
pockets = []
pockets.append(self.deck_.pop())
bisect.insort(pockets, self.deck_.pop())
return pockets
def deal_flop(self):
# Burn one card
self.deck_.pop()
# Flop (three community cards)
self.communitycards_.append(self.deck_.pop())
self.communitycards_.append(self.deck_.pop())
self.communitycards_.append(self.deck_.pop())
print(self)
def deal_turn(self):
# Burn one card
self.deck_.pop()
# Turn (single community card)
self.communitycards_.append(self.deck_.pop())
print(self)
def deal_river(self):
# Burn one card
self.deck_.pop()
# River (last community card)
self.communitycards_.append(self.deck_.pop())
print(self)
def __str__(self):
return "\n\t\t" + str(self.communitycards_) + "\n"
# Test Dealer
#D = Dealer()
#pocket = D.deal_pockets()
#print(pocket)
#D.deal_flop()
#D.deal_turn()
#D.deal_river()
#H = Hand(pocket, D.communitycards_)
#print(H)