Added shuffling after 75% of cards played

This commit is contained in:
2023-01-05 17:00:42 +10:00
parent 8778862986
commit fdb704af08
3 changed files with 15 additions and 10 deletions

View File

@@ -58,6 +58,12 @@ def getHandTotal(hand):
i += card
return i
def showDeck(deck):
string = ""
for card in deck:
string += convertNumberToCard(card)
return string
class BlackJack:
def __init__(self):
self.playerTurn = True
@@ -78,7 +84,7 @@ class BlackJack:
self.discard.extend(self.playerHand)
self.playerHand.clear()
self.discard.extend(self.dealerHand)
self.playerHand.clear()
self.dealerHand.clear()
def deal(self):
generateHand(self.playerHand, self.deck)
@@ -137,8 +143,8 @@ class BlackJack:
self.ledger.writeLedger(ID)
playerStats = self.ledger.readLedger
while not gameOver:
self.deal()
while not gameOver:
playerWinState = self.checkHandState(self.playerHand)
dealerWinState = self.checkHandState(self.dealerHand)
gameOver = self.checkGameOver(playerWinState) or self.checkGameOver(dealerWinState)
@@ -182,22 +188,21 @@ class BlackJack:
if playerWinState == "w":
await send("You won!")
win = (2*bet, 1, 0, ID)
self.ledger.updateLedger(playerStats, win)
# self.ledger.updateLedger(playerStats, win)
elif playerWinState == "l":
await send("You busted!")
loss = (-bet, 0, 1, ID)
self.ledger.updateLedger(playerStats, loss)
# self.ledger.updateLedger(playerStats, loss)
elif dealerWinState == "w":
await send("The Dealer reached 21 before you!")
loss = (-bet, 0, 1, ID)
self.ledger.updateLedger(playerStats, loss)
# self.ledger.updateLedger(playerStats, loss)
elif dealerWinState == "l":
await send("The Dealer busted before you!")
win = (2*bet, 1, 0, ID)
self.ledger.updateLedger(playerStats, win)
# self.ledger.updateLedger(playerStats, win)
self.returnCards()
if len(self.deck) < 0.25 * 52:
await send("Shuffling Deck")
self.returnCards()
self.shuffle()

View File