🃏 Double splitting

This commit is contained in:
Nikolaj Danger
2020-08-03 13:39:11 +02:00
parent 90f82f54c5
commit 0a1b382e1a
3 changed files with 433 additions and 255 deletions

View File

@ -485,7 +485,7 @@ async def parseCommands(message,content):
# Runs a game of Blackjack # Runs a game of Blackjack
elif content.startswith("blackjack"): elif content.startswith("blackjack"):
try: #try:
# Starts the game # Starts the game
if content == "blackjack" or content == "blackjack ": if content == "blackjack" or content == "blackjack ":
cardsLeft = 0 cardsLeft = 0
@ -615,23 +615,26 @@ async def parseCommands(message,content):
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID) await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
except: except:
logThis("Something fucked up",str(message.channel)) logThis("Something fucked up",str(message.channel))
await message.channel.send("something fucked up")
# Splitting hand # Splitting hand
elif content.startswith("blackjack split"): elif content.startswith("blackjack split"):
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name) commands = content.split(" ")
try:
handNumber = int(commands[2])
except:
handNumber = 0
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name,handNumber)
await message.channel.send(response) await message.channel.send(response)
#try: try:
if roundDone[0] == "T": if roundDone[0] == "T":
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"] gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
logThis("Split calling blackjackLoop()",str(message.channel)) logThis("Split calling blackjackLoop()",str(message.channel))
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID) await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
#except: except:
# logThis("Something fucked up") logThis("Something fucked up")
# await message.channel.send("something fucked up")
# Returning current hi-lo value # Returning current hi-lo value
elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj": elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj":
@ -663,8 +666,8 @@ async def parseCommands(message,content):
else: else:
logThis("Not a command (error code 1301)") logThis("Not a command (error code 1301)")
await message.channel.send("I didn't quite understand that (error code 1301)") await message.channel.send("I didn't quite understand that (error code 1301)")
except: #except:
logThis("Something went wrong (error code 1300)") # logThis("Something went wrong (error code 1300)")
# Runs a game of four in a row # Runs a game of four in a row
elif content.startswith("fourinarow"): elif content.startswith("fourinarow"):

View File

@ -146,7 +146,7 @@ def blackjackContinue(channel):
data["blackjack games"][channel]["user hands"][user]["hit"] = False data["blackjack games"][channel]["user hands"][user]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"]: if data["blackjack games"][channel]["user hands"][user]["split"] > 0:
if data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] == False: if data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["other hand"]["standing"] = True data["blackjack games"][channel]["user hands"][user]["other hand"]["standing"] = True
@ -160,6 +160,34 @@ def blackjackContinue(channel):
data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] = False data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"] > 1:
if data["blackjack games"][channel]["user hands"][user]["third hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] = True
if data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] == False:
allStanding = False
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["third hand"]["hand"]) >= 21 or data["blackjack games"][channel]["user hands"][user]["third hand"]["doubled"]:
data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] = True
else:
preAllStanding = False
data["blackjack games"][channel]["user hands"][user]["third hand"]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"] > 2:
if data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] = True
if data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] == False:
allStanding = False
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hand"]) >= 21 or data["blackjack games"][channel]["user hands"][user]["fourth hand"]["doubled"]:
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] = True
else:
preAllStanding = False
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hit"] = False
if allStanding: if allStanding:
data["blackjack games"][channel]["all standing"] = True data["blackjack games"][channel]["all standing"] = True
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
@ -190,17 +218,19 @@ def blackjackHit(channel,user,handNumber = 0):
data = json.load(f) data = json.load(f)
if user in data["blackjack games"][channel]["user hands"]: if user in data["blackjack games"][channel]["user hands"]:
if data["blackjack games"][channel]["user hands"][user]["split"] == False: if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False handNumber = 0
else: else:
if handNumber != 0: if handNumber != 0:
if handNumber == 1: if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2: elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"] hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 4:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else: else:
logThis(user+" tried to hit without specifying which hand") logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with." return "You have to specify the hand you're hitting with."
@ -219,8 +249,12 @@ def blackjackHit(channel,user,handNumber = 0):
if handValue > 21: if handValue > 21:
hand["busted"] = True hand["busted"] = True
if otherHand: if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
elif handNumber == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
else: else:
data["blackjack games"][channel]["user hands"][user] = hand data["blackjack games"][channel]["user hands"][user] = hand
@ -234,10 +268,18 @@ def blackjackHit(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False: if person["hit"] == False and person["standing"] == False:
roundDone = False roundDone = False
if person["split"]: if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False: if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"]) return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else: else:
logThis(user+" is already standing") logThis(user+" is already standing")
@ -258,31 +300,31 @@ def blackjackDouble(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
if data["blackjack games"][channel]["user hands"][user]["split"] == False: if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False handNumber = 0
correctRound = 1
else: else:
if handNumber != 0: if handNumber != 0:
if handNumber == 1: if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2: elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"] hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else: else:
logThis(user+" tried to double without specifying which hand") logThis(user+" tried to double without specifying which hand")
return "You have to specify the hand you're doubling down.","" return "You have to specify the hand you're doubling down.",""
else: else:
logThis(user+" tried to double without specifying which hand") logThis(user+" tried to double without specifying which hand")
return "You have to specify the hand you're doubling down.","" return "You have to specify the hand you're doubling down.",""
correctRound = 2
if data["blackjack games"][channel]["round"] > 0: if data["blackjack games"][channel]["round"] > 0:
if hand["hit"] == False: if hand["hit"] == False:
if hand["standing"] == False: if hand["standing"] == False:
if data["blackjack games"][channel]["round"] == correctRound: if len(hand["hand"]) == 2:
bet = hand["bet"] bet = hand["bet"]
if money.checkBalance(user) >= bet: if money.checkBalance(user) >= bet:
money.addMoney(user,-1 * bet) money.addMoney(user,-1 * bet)
@ -300,8 +342,12 @@ def blackjackDouble(channel,user,handNumber = 0):
if handValue > 21: if handValue > 21:
hand["busted"] = True hand["busted"] = True
if otherHand: if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
elif handNumber == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
else: else:
data["blackjack games"][channel]["user hands"][user] = hand data["blackjack games"][channel]["user hands"][user] = hand
@ -314,10 +360,18 @@ def blackjackDouble(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False: if person["hit"] == False and person["standing"] == False:
roundDone = False roundDone = False
if person["split"]: if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False: if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet and drawing another card.",str(roundDone)[0] + str(data["blackjack games"][channel]["round"]) return "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet and drawing another card.",str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else: else:
@ -342,17 +396,19 @@ def blackjackStand(channel,user,handNumber = 0):
data = json.load(f) data = json.load(f)
if user in data["blackjack games"][channel]["user hands"]: if user in data["blackjack games"][channel]["user hands"]:
if data["blackjack games"][channel]["user hands"][user]["split"] == False: if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False handNumber = 0
else: else:
if handNumber != 0: if handNumber != 0:
if handNumber == 1: if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user] hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2: elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"] hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 4:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else: else:
logThis(user+" tried to hit without specifying which hand") logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with." return "You have to specify the hand you're hitting with."
@ -374,10 +430,18 @@ def blackjackStand(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False: if person["hit"] == False and person["standing"] == False:
roundDone = False roundDone = False
if person["split"]: if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False: if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"]) return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else: else:
logThis(user+" is already standing") logThis(user+" is already standing")
@ -393,46 +457,92 @@ def blackjackStand(channel,user,handNumber = 0):
return "You have to enter the game before you can stand" return "You have to enter the game before you can stand"
# When players try to split # When players try to split
def blackjackSplit(channel,user): def blackjackSplit(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
if data["blackjack games"][channel]["round"] > 0: if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
if data["blackjack games"][channel]["user hands"][user]["hit"] == False: hand = data["blackjack games"][channel]["user hands"][user]
if data["blackjack games"][channel]["user hands"][user]["standing"] == False: newHand = data["blackjack games"][channel]["user hands"][user]["other hand"]
if data["blackjack games"][channel]["round"] == 1: handNumber = 0
firstCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][0]]) otherHand = 2
secondCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][1]]) else:
if handNumber != 0:
if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user]
elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
else:
logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with."
if data["blackjack games"][channel]["user hands"][user]["split"] == 1:
newHand = data["blackjack games"][channel]["user hands"][user]["third hand"]
otherHand = 3
else:
newHand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
otherHand = 4
else:
logThis(user+" tried to split without specifying which hand")
return "You have to specify the hand you're splitting.",""
if data["blackjack games"][channel]["user hands"][user]["split"] < 3:
if data["blackjack games"][channel]["round"] != 0:
if hand["hit"] == False:
if hand["standing"] == False:
if len(hand["hand"]) == 2:
firstCard = calcHandValue([hand["hand"][0]])
secondCard = calcHandValue([hand["hand"][1]])
if firstCard == secondCard: if firstCard == secondCard:
bet = data["blackjack games"][channel]["user hands"][user]["bet"] bet = hand["bet"]
if money.checkBalance(user) >= bet: if money.checkBalance(user) >= bet:
money.addMoney(user,-1 * bet) money.addMoney(user,-1 * bet)
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
data["blackjack games"][channel]["user hands"][user]["hit"] = True hand["hit"] = True
data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] = True newHand["hit"] = True
data["blackjack games"][channel]["user hands"][user]["split"] = True
data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"] = data["blackjack games"][channel]["user hands"][user]["bet"] newHand = {
"hand":[],"bet":0,"standing":False,"busted":False,
"blackjack":False,"hit":True,"doubled":False}
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(data["blackjack games"][channel]["user hands"][user]["hand"].pop(1)) newHand["bet"] = hand["bet"]
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(drawCard(channel))
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard(channel))
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) newHand["hand"].append(hand["hand"].pop(1))
otherHandValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"]) newHand["hand"].append(drawCard(channel))
hand["hand"].append(drawCard(channel))
handValue = calcHandValue(hand["hand"])
otherHandValue = calcHandValue(newHand["hand"])
if handValue > 21: if handValue > 21:
data["blackjack games"][channel]["user hands"][user]["busted"] = True hand["busted"] = True
elif handValue == 21: elif handValue == 21:
data["blackjack games"][channel]["user hands"][user]["blackjack"] = True han["blackjack"] = True
if otherHandValue > 21: if otherHandValue > 21:
data["blackjack games"][channel]["user hands"][user]["other hand"]["busted"] = True newHand["busted"] = True
elif otherHandValue == 21: elif otherHandValue == 21:
data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] = True newHand["blackjack"] = True
if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
else:
data["blackjack games"][channel]["user hands"][user] = hand
if otherHand == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = newHand
elif otherHand == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = newHand
else:
data["blackjack games"][channel]["user hands"][user]["other hand"] = newHand
data["blackjack games"][channel]["user hands"][user]["split"] += 1
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4) json.dump(data,f,indent=4)
@ -443,10 +553,18 @@ def blackjackSplit(channel,user):
if person["hit"] == False and person["standing"] == False: if person["hit"] == False and person["standing"] == False:
roundDone = False roundDone = False
if person["split"]: if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False: if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return "Splitting "+user+"'s hand into 2. Adding their original bet to the second hand. You can use \"!Blackjack hit/stand/double 1\" and \"!Blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(data["blackjack games"][channel]["round"]) return "Splitting "+user+"'s hand into 2. Adding their original bet to the second hand. You can use \"!Blackjack hit/stand/double 1\" and \"!Blackjack hit/stand/double 2\" to play the different hands.",str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else: else:
logThis(user+" doesn't have enough GwendoBucks") logThis(user+" doesn't have enough GwendoBucks")
@ -455,7 +573,7 @@ def blackjackSplit(channel,user):
logThis(user+" tried to split 2 different cards") logThis(user+" tried to split 2 different cards")
return "Your cards need to have the same value to split","" return "Your cards need to have the same value to split",""
else: else:
logThis(user+" tried to split on round "+data["blackjack games"][channel]["round"]) logThis(user+" tried to split later than they could")
return "You can only split on the first round","" return "You can only split on the first round",""
else: else:
logThis(user+" is already standing") logThis(user+" is already standing")
@ -466,6 +584,9 @@ def blackjackSplit(channel,user):
else: else:
logThis(user+" tried to split on the 0th round") logThis(user+" tried to split on the 0th round")
return "You can't split before you see your cards","" return "You can't split before you see your cards",""
else:
logThis(user+" tried to split more than three times")
return "You can only split 3 times",""
# Player enters the game and draws a hand # Player enters the game and draws a hand
def blackjackPlayerDrawHand(channel,user,bet): def blackjackPlayerDrawHand(channel,user,bet):
@ -491,15 +612,11 @@ def blackjackPlayerDrawHand(channel,user,bet):
if handValue == 21: if handValue == 21:
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand, data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
"bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True, "bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True,
"doubled":False,"split":False,"other hand":{ "doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False}}
else: else:
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand, data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True, "bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False,"split":False,"other hand":{ "doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False}}
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4) json.dump(data,f,indent=4)
@ -585,7 +702,7 @@ def blackjackFinish(channel):
reason = "(highest value)" reason = "(highest value)"
if data["blackjack games"][channel]["user hands"][user]["split"]: if data["blackjack games"][channel]["user hands"][user]["split"] > 0:
winnings -= data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"] winnings -= data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
if data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False: if data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
reason += "(blackjack)" reason += "(blackjack)"
@ -607,6 +724,50 @@ def blackjackFinish(channel):
else: else:
reason += "(highest value)" reason += "(highest value)"
if data["blackjack games"][channel]["user hands"][user]["split"] > 1:
winnings -= data["blackjack games"][channel]["user hands"][user]["third hand"]["bet"]
if data["blackjack games"][channel]["user hands"][user]["third hand"]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
reason += "(blackjack)"
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["third hand"]["bet"])
elif data["blackjack games"][channel]["dealer blackjack"]:
reason += "(dealer blackjack)"
elif data["blackjack games"][channel]["user hands"][user]["third hand"]["busted"]:
reason += "(busted)"
else:
if data["blackjack games"][channel]["dealer busted"]:
reason += "(dealer busted)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["third hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["third hand"]["hand"]) > dealerValue:
reason += "(highest value)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["third hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["third hand"]["hand"]) == dealerValue:
reason += "(pushed)"
winnings += data["blackjack games"][channel]["user hands"][user]["third hand"]["bet"]
else:
reason += "(highest value)"
if data["blackjack games"][channel]["user hands"][user]["split"] > 2:
winnings -= data["blackjack games"][channel]["user hands"][user]["fourth hand"]["bet"]
if data["blackjack games"][channel]["user hands"][user]["fourth hand"]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
reason += "(blackjack)"
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["fourth hand"]["bet"])
elif data["blackjack games"][channel]["dealer blackjack"]:
reason += "(dealer blackjack)"
elif data["blackjack games"][channel]["user hands"][user]["fourth hand"]["busted"]:
reason += "(busted)"
else:
if data["blackjack games"][channel]["dealer busted"]:
reason += "(dealer busted)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["fourth hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hand"]) > dealerValue:
reason += "(highest value)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["fourth hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hand"]) == dealerValue:
reason += "(pushed)"
winnings += data["blackjack games"][channel]["user hands"][user]["fourth hand"]["bet"]
else:
reason += "(highest value)"
if winnings < 0: if winnings < 0:

View File

@ -33,7 +33,21 @@ def drawImage(channel):
key, value = list(hands.items())[x] key, value = list(hands.items())[x]
userHand = drawHand(value["hand"],False,value["busted"],value["blackjack"]) userHand = drawHand(value["hand"],False,value["busted"],value["blackjack"])
if value["split"]: if value["split"] == 3:
table.paste(userHand,(32-borderSmol+(384*placement[x]),280-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),420-borderSmol),userOtherHand)
userThirdHand = drawHand(value["third hand"]["hand"],False,value["third hand"]["busted"],value["third hand"]["blackjack"])
table.paste(userThirdHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userOtherHand)
userFourthHand = drawHand(value["fourth hand"]["hand"],False,value["fourth hand"]["busted"],value["fourth hand"]["blackjack"])
table.paste(userFourthHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)
elif value["split"] == 2:
table.paste(userHand,(32-borderSmol+(384*placement[x]),420-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userOtherHand)
userThirdHand = drawHand(value["third hand"]["hand"],False,value["third hand"]["busted"],value["third hand"]["blackjack"])
table.paste(userThirdHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)
elif value["split"] == 1:
table.paste(userHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userHand) table.paste(userHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"]) userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand) table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)