End of game messages
This commit is contained in:
53
BlackJack.py
53
BlackJack.py
@@ -7,8 +7,6 @@ PLAYERTURN = 1
|
|||||||
DEALERTURN = 2
|
DEALERTURN = 2
|
||||||
FINISHED = 3
|
FINISHED = 3
|
||||||
OVER = 5
|
OVER = 5
|
||||||
CHECKING = 6
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Class which describes playing cards
|
Class which describes playing cards
|
||||||
@@ -150,9 +148,10 @@ class Hand():
|
|||||||
# Dynamically add ace value based on ideal rules
|
# Dynamically add ace value based on ideal rules
|
||||||
card = 11
|
card = 11
|
||||||
for _ in range(aces):
|
for _ in range(aces):
|
||||||
if value < 20:
|
|
||||||
|
if value <= 10:
|
||||||
card = 11
|
card = 11
|
||||||
if (value + card) >= 21:
|
if value > 10:
|
||||||
card = 1
|
card = 1
|
||||||
value += card
|
value += card
|
||||||
|
|
||||||
@@ -230,12 +229,54 @@ class BlackJack:
|
|||||||
gameState = FINISHED
|
gameState = FINISHED
|
||||||
|
|
||||||
if 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 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.playerHand)
|
||||||
self.discard_hand(self.dealerHand)
|
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:
|
if len(self.deck) < 0.25 * 51:
|
||||||
self.deck.return_all_from_discard()
|
self.deck.return_all_from_discard()
|
||||||
self.deck.shuffle()
|
self.deck.shuffle()
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user