even blacker jacks

This commit is contained in:
Adam 2022-12-22 22:32:15 -05:00
parent a37278e937
commit 53e80090d9
3 changed files with 15 additions and 5 deletions

View file

@ -19,7 +19,7 @@ def main():
while game.active:
screen.update(game)
if player.blackjack():
if player.blackjack(game):
game.active = False
print('Blackjack!')
break
@ -44,18 +44,19 @@ def main():
while dealer.score(game) < 17:
dealer.hand.append(deck.draw())
screen.update(game)
if not game.active:
game.score()
kill = False
screen = Screen()
print(screen.intro)
num_decks = input('How many decks? (1-8): ')
if num_decks == 'q':
kill = True
deck = Deck(num_decks)
while not kill:
@ -64,4 +65,6 @@ while not kill:
match user_input.lower():
case 'n':
kill = True
case 'q':
kill = True

View file

@ -24,4 +24,9 @@ class GameMaster:
if player.score(self) > 21:
self.active = False
status = player.name + ' Bust!'
if self.dealer.blackjack(self):
self.active = False
status = 'Dealer Blackjack!'
print(status)

View file

@ -24,6 +24,8 @@ class Player:
if self.score(game) > 21:
return True
def blackjack(self):
if self.tally_hand() in [[10,11],[11,10]]:
def blackjack(self, game):
if game.active and self.name == 'Dealer':
return False
elif self.tally_hand() in [[10,11],[11,10]]:
return True