Fixed multiple session bug for blackjack

This commit is contained in:
2023-11-30 16:35:37 +10:00
parent a6bc671231
commit 9501737b43
3 changed files with 8 additions and 0 deletions

BIN
ledger.db

Binary file not shown.

View File

@@ -198,6 +198,7 @@ class BlackJack:
self.playerHand = Hand() self.playerHand = Hand()
self.dealerHand = Hand() self.dealerHand = Hand()
self.ledger = Ledger() self.ledger = Ledger()
self.playing = False
def deal_card(self, hand): def deal_card(self, hand):
hand.add_to_hand(self.deck.take_from_deck()) hand.add_to_hand(self.deck.take_from_deck())
@@ -227,6 +228,12 @@ class BlackJack:
await send(string) await send(string)
async def play_game(self, ID, bet, recv, send): async def play_game(self, ID, bet, recv, send):
if self.playing:
await send("Game in Progress")
return
else:
self.playing = True
gameState = INIT gameState = INIT
while gameState != OVER: while gameState != OVER:
@@ -328,6 +335,7 @@ class BlackJack:
self.deck.shuffle() self.deck.shuffle()
await send("Everyday I'm shuffling") await send("Everyday I'm shuffling")
gameState = OVER gameState = OVER
self.playing = False
def main(): def main():
game = BlackJack() game = BlackJack()