From 11b391c4373fa6ea70cb63109b3789585ecdd7ea Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 5 Sep 2022 04:34:30 +0200 Subject: [PATCH] fix blackjack when hitting blackjack --- files/helpers/blackjack.py | 5 +++-- files/routes/casino.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/files/helpers/blackjack.py b/files/helpers/blackjack.py index 866d6623c..f32e451c1 100644 --- a/files/helpers/blackjack.py +++ b/files/helpers/blackjack.py @@ -51,7 +51,7 @@ def get_active_game(gambler): game = g.db.query(Casino_Game) \ .filter(Casino_Game.active == True, Casino_Game.kind == 'blackjack', - Casino_Game.user_id == gambler.id).first() + Casino_Game.user_id == gambler.id).one_or_none() if game: return game, json.loads(game.game_state) @@ -95,7 +95,8 @@ def apply_blackjack_result(gambler): gambler.winnings += reward game.winnings += reward - game.active = False + if result not in ('push','blackjack'): + game.active = False g.db.add(game) diff --git a/files/routes/casino.py b/files/routes/casino.py index f2f0619ea..3a1604c86 100644 --- a/files/routes/casino.py +++ b/files/routes/casino.py @@ -79,6 +79,8 @@ def deal_blackjack(v): if game and game.active: safe_state = get_safe_game_state(v) + if safe_state['status'] in ('push','blackjack'): + game.active = False return {"game_state": safe_state, "gambler": { "coins": v.coins, "procoins": v.procoins }} else: return {"game_state": game_state, "gambler": { "coins": v.coins, "procoins": v.procoins }}