-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.py
44 lines (32 loc) · 884 Bytes
/
game.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
from player import Player
from deck import Deck
from dealer import Dealer
import random
class Game(object):
def __init__(self):
self.player = Player()
self.deck = Deck()
self.dealer = Dealer()
self.isFirstDeal = True
def dealToPlayer(self):
if self.isFirstDeal:
card1 = self.deck.randomDraw()
card2 = self.deck.randomDraw()
self.player.hand.extend([card1, card2])
self.isFirstDeal = False
else:
card = self.deck.randomDraw()
self.player.hand.append(card)
pass
print "Your Hand: ", self.player.hand
def play_round(self):
while self.player.play_action().low() == "h": #returns Hit or Stand"
if self.player.choice.low() == "h":
self.player.dealToPlayer()
else: # end of the game
self.player.hand
self.dealer.play_action()
def play_game(self):
if __name__ = '__main__':
g = Game()
g.play_game()