Fixed multiple session bug for blackjack
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user