even blacker jacks
This commit is contained in:
parent
a37278e937
commit
53e80090d9
3 changed files with 15 additions and 5 deletions
|
@ -19,7 +19,7 @@ def main():
|
||||||
|
|
||||||
while game.active:
|
while game.active:
|
||||||
screen.update(game)
|
screen.update(game)
|
||||||
if player.blackjack():
|
if player.blackjack(game):
|
||||||
game.active = False
|
game.active = False
|
||||||
print('Blackjack!')
|
print('Blackjack!')
|
||||||
break
|
break
|
||||||
|
@ -44,18 +44,19 @@ def main():
|
||||||
while dealer.score(game) < 17:
|
while dealer.score(game) < 17:
|
||||||
dealer.hand.append(deck.draw())
|
dealer.hand.append(deck.draw())
|
||||||
|
|
||||||
|
|
||||||
screen.update(game)
|
screen.update(game)
|
||||||
if not game.active:
|
if not game.active:
|
||||||
game.score()
|
game.score()
|
||||||
|
|
||||||
|
|
||||||
kill = False
|
kill = False
|
||||||
screen = Screen()
|
screen = Screen()
|
||||||
|
|
||||||
print(screen.intro)
|
print(screen.intro)
|
||||||
|
|
||||||
num_decks = input('How many decks? (1-8): ')
|
num_decks = input('How many decks? (1-8): ')
|
||||||
|
if num_decks == 'q':
|
||||||
|
kill = True
|
||||||
|
|
||||||
deck = Deck(num_decks)
|
deck = Deck(num_decks)
|
||||||
|
|
||||||
while not kill:
|
while not kill:
|
||||||
|
@ -64,4 +65,6 @@ while not kill:
|
||||||
match user_input.lower():
|
match user_input.lower():
|
||||||
case 'n':
|
case 'n':
|
||||||
kill = True
|
kill = True
|
||||||
|
case 'q':
|
||||||
|
kill = True
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,9 @@ class GameMaster:
|
||||||
if player.score(self) > 21:
|
if player.score(self) > 21:
|
||||||
self.active = False
|
self.active = False
|
||||||
status = player.name + ' Bust!'
|
status = player.name + ' Bust!'
|
||||||
|
|
||||||
|
if self.dealer.blackjack(self):
|
||||||
|
self.active = False
|
||||||
|
status = 'Dealer Blackjack!'
|
||||||
|
|
||||||
print(status)
|
print(status)
|
||||||
|
|
|
@ -24,6 +24,8 @@ class Player:
|
||||||
if self.score(game) > 21:
|
if self.score(game) > 21:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def blackjack(self):
|
def blackjack(self, game):
|
||||||
if self.tally_hand() in [[10,11],[11,10]]:
|
if game.active and self.name == 'Dealer':
|
||||||
|
return False
|
||||||
|
elif self.tally_hand() in [[10,11],[11,10]]:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Add table
Reference in a new issue