From bb7d4c9f2c686d7c91cd21f134bf27d36283ca16 Mon Sep 17 00:00:00 2001 From: moneromooo Date: Fri, 23 Jan 2015 10:52:32 +0000 Subject: [PATCH] blackjack: fix double doubling the wrong bet amount It would double the current full amount bet, rather than the original bet of the current hand only. Also fix an error message using a variable before it's initialized when telling the player his/her balance is not enough when doing so. --- tipbot/modules/blackjack.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tipbot/modules/blackjack.py b/tipbot/modules/blackjack.py index aa36c2e..bb8454d 100644 --- a/tipbot/modules/blackjack.py +++ b/tipbot/modules/blackjack.py @@ -585,6 +585,7 @@ def Blackjack(link,cmd): players[identity] = { 'deck': MakeNewDeck(config.blackjack_decks,seed), 'amount': total_units_wagered, + 'base_amount': units, 'player_hands': [dict({ 'amount': units, 'hand': [], @@ -818,6 +819,7 @@ def Split(link,cmd): if not enough: link.send("%s: %s - please refund your account to continue playing" % (link.user.nick, reason)) return + idx = players[identity]['player_current_hand'] hand = GetPlayerCurrentHand(link) if len(hand)!=2 or GetCardScore(hand[0])!=GetCardScore(hand[1]): link.send("%s: only pairs with the same value can be split" % (link.user.nick)) @@ -825,12 +827,11 @@ def Split(link,cmd): if len(players[identity]['player_hands']) >= config.blackjack_split_to: link.send("%s: you can only split to %d" % (link.user.nick, config.blackjack_split_to)) return - enough, reason = IsPlayerBalanceAtLeast(link,units*2) + enough, reason = IsPlayerBalanceAtLeast(link,units+players[identity]['base_amount']) if not enough: link.send("%s: you do not have enough %s in your account to split hand %d" % (link.user.nick,coinspecs.name,idx+1)) return - players[identity]['amount'] = players[identity]['amount'] * 2 - idx = players[identity]['player_current_hand'] + players[identity]['amount'] = players[identity]['amount'] + players[identity]['base_amount'] RecordMove(link,"split") log_log('splitting hand %d' % idx) split_card = hand[0]