diff --git a/BlackJack.py b/BlackJack.py index c69a4fb..c0b65c0 100644 --- a/BlackJack.py +++ b/BlackJack.py @@ -7,8 +7,6 @@ PLAYERTURN = 1 DEALERTURN = 2 FINISHED = 3 OVER = 5 -CHECKING = 6 - """ Class which describes playing cards @@ -150,9 +148,10 @@ class Hand(): # Dynamically add ace value based on ideal rules card = 11 for _ in range(aces): - if value < 20: + + if value <= 10: card = 11 - if (value + card) >= 21: + if value > 10: card = 1 value += card @@ -230,12 +229,54 @@ class BlackJack: gameState = FINISHED if gameState == FINISHED: - + + playerBlackJack = False + dealerBlackJack = False + playerBust = False + dealerBust = False + playerHigher = False + dealerHigher = False + tie = False + playerScore = int(repr(self.playerHand)) + dealerScore = int(repr(self.dealerHand)) await self.show_cards(send, True) - await send("You won or lost idk lmao") + if playerScore == 21: + playerBlackJack = True + if dealerScore == 21: + dealerBlackJack = True + + if playerScore > 21: + playerBust = True + if dealerScore > 21: + dealerBust = True + + if dealerScore > playerScore: + dealerHigher = True + elif playerScore > dealerScore: + playerHigher = True + else: + tie = True self.discard_hand(self.playerHand) self.discard_hand(self.dealerHand) + if tie: + await send("You tied") + elif playerBlackJack: + await send("You reached BlackJack!") + elif dealerBlackJack: + await send("The dealer reached BlackJack!") + elif playerBust: + await send("You busted!") + elif dealerBust: + await send("The dealer busted!") + elif playerHigher: + await send("You won!") + elif dealerHigher: + await send("You lost!") + else: + await send("Report this game to my creator!") + + if len(self.deck) < 0.25 * 51: self.deck.return_all_from_discard() self.deck.shuffle() diff --git a/__pycache__/BlackJack.cpython-310.pyc b/__pycache__/BlackJack.cpython-310.pyc index 8caf4f8..5a665c5 100644 Binary files a/__pycache__/BlackJack.cpython-310.pyc and b/__pycache__/BlackJack.cpython-310.pyc differ