From 53e80090d9a680b871d9d436df502bf2c7889869 Mon Sep 17 00:00:00 2001 From: Adam <24621027+WhiteDopeOnPunk@users.noreply.github.com> Date: Thu, 22 Dec 2022 22:32:15 -0500 Subject: [PATCH] even blacker jacks --- blackjack.py | 9 ++++++--- src/gamemaster.py | 5 +++++ src/player.py | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/blackjack.py b/blackjack.py index a30ca89..07b66f0 100644 --- a/blackjack.py +++ b/blackjack.py @@ -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 diff --git a/src/gamemaster.py b/src/gamemaster.py index c3d1748..ece2d9f 100644 --- a/src/gamemaster.py +++ b/src/gamemaster.py @@ -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) diff --git a/src/player.py b/src/player.py index 9583d12..c290165 100644 --- a/src/player.py +++ b/src/player.py @@ -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