End of game messages

This commit is contained in:
2023-07-19 14:13:53 +10:00
parent 01fb3771df
commit 464c23b502
2 changed files with 47 additions and 6 deletions

View File

@@ -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
@@ -231,11 +230,53 @@ class BlackJack:
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()