|
|
|
@ -146,7 +146,7 @@ def blackjackContinue(channel):
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
data["blackjack games"][channel]["all standing"] = True
|
|
|
|
|
with open("resources/games/games.json", "w") as f:
|
|
|
|
@ -190,17 +218,19 @@ def blackjackHit(channel,user,handNumber = 0):
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
otherHand = False
|
|
|
|
|
handNumber = 0
|
|
|
|
|
else:
|
|
|
|
|
if handNumber != 0:
|
|
|
|
|
if handNumber == 1:
|
|
|
|
|
hand = data["blackjack games"][channel]["user hands"][user]
|
|
|
|
|
otherHand = False
|
|
|
|
|
elif handNumber == 2:
|
|
|
|
|
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:
|
|
|
|
|
logThis(user+" tried to hit without specifying which hand")
|
|
|
|
|
return "You have to specify the hand you're hitting with."
|
|
|
|
@ -219,8 +249,12 @@ def blackjackHit(channel,user,handNumber = 0):
|
|
|
|
|
if handValue > 21:
|
|
|
|
|
hand["busted"] = True
|
|
|
|
|
|
|
|
|
|
if otherHand:
|
|
|
|
|
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
|
|
|
|
|
elif handNumber == 4:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
|
|
|
|
|
else:
|
|
|
|
|
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:
|
|
|
|
|
roundDone = False
|
|
|
|
|
|
|
|
|
|
if person["split"]:
|
|
|
|
|
if person["split"] > 0:
|
|
|
|
|
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == 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"])
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" is already standing")
|
|
|
|
@ -258,31 +300,31 @@ def blackjackDouble(channel,user,handNumber = 0):
|
|
|
|
|
with open("resources/games/games.json", "r") as 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]
|
|
|
|
|
otherHand = False
|
|
|
|
|
correctRound = 1
|
|
|
|
|
handNumber = 0
|
|
|
|
|
else:
|
|
|
|
|
if handNumber != 0:
|
|
|
|
|
if handNumber == 1:
|
|
|
|
|
hand = data["blackjack games"][channel]["user hands"][user]
|
|
|
|
|
otherHand = False
|
|
|
|
|
elif handNumber == 2:
|
|
|
|
|
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:
|
|
|
|
|
logThis(user+" tried to double without specifying which hand")
|
|
|
|
|
return "You have to specify the hand you're doubling down.",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to double without specifying which hand")
|
|
|
|
|
return "You have to specify the hand you're doubling down.",""
|
|
|
|
|
correctRound = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data["blackjack games"][channel]["round"] > 0:
|
|
|
|
|
if hand["hit"] == False:
|
|
|
|
|
if hand["standing"] == False:
|
|
|
|
|
if data["blackjack games"][channel]["round"] == correctRound:
|
|
|
|
|
if len(hand["hand"]) == 2:
|
|
|
|
|
bet = hand["bet"]
|
|
|
|
|
if money.checkBalance(user) >= bet:
|
|
|
|
|
money.addMoney(user,-1 * bet)
|
|
|
|
@ -300,8 +342,12 @@ def blackjackDouble(channel,user,handNumber = 0):
|
|
|
|
|
if handValue > 21:
|
|
|
|
|
hand["busted"] = True
|
|
|
|
|
|
|
|
|
|
if otherHand:
|
|
|
|
|
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
|
|
|
|
|
elif handNumber == 4:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
|
|
|
|
|
else:
|
|
|
|
|
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:
|
|
|
|
|
roundDone = False
|
|
|
|
|
|
|
|
|
|
if person["split"]:
|
|
|
|
|
if person["split"] > 0:
|
|
|
|
|
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == 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"])
|
|
|
|
|
else:
|
|
|
|
@ -342,17 +396,19 @@ def blackjackStand(channel,user,handNumber = 0):
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
otherHand = False
|
|
|
|
|
handNumber = 0
|
|
|
|
|
else:
|
|
|
|
|
if handNumber != 0:
|
|
|
|
|
if handNumber == 1:
|
|
|
|
|
hand = data["blackjack games"][channel]["user hands"][user]
|
|
|
|
|
otherHand = False
|
|
|
|
|
elif handNumber == 2:
|
|
|
|
|
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:
|
|
|
|
|
logThis(user+" tried to hit without specifying which hand")
|
|
|
|
|
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:
|
|
|
|
|
roundDone = False
|
|
|
|
|
|
|
|
|
|
if person["split"]:
|
|
|
|
|
if person["split"] > 0:
|
|
|
|
|
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == 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"])
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" is already standing")
|
|
|
|
@ -393,79 +457,136 @@ def blackjackStand(channel,user,handNumber = 0):
|
|
|
|
|
return "You have to enter the game before you can stand"
|
|
|
|
|
|
|
|
|
|
# When players try to split
|
|
|
|
|
def blackjackSplit(channel,user):
|
|
|
|
|
def blackjackSplit(channel,user,handNumber = 0):
|
|
|
|
|
with open("resources/games/games.json", "r") as f:
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
if data["blackjack games"][channel]["round"] > 0:
|
|
|
|
|
if data["blackjack games"][channel]["user hands"][user]["hit"] == False:
|
|
|
|
|
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
|
|
|
|
if data["blackjack games"][channel]["round"] == 1:
|
|
|
|
|
firstCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][0]])
|
|
|
|
|
secondCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][1]])
|
|
|
|
|
if firstCard == secondCard:
|
|
|
|
|
bet = data["blackjack games"][channel]["user hands"][user]["bet"]
|
|
|
|
|
if money.checkBalance(user) >= bet:
|
|
|
|
|
money.addMoney(user,-1 * bet)
|
|
|
|
|
with open("resources/games/games.json", "r") as f:
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["hit"] = True
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["other hand"]["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"]
|
|
|
|
|
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(data["blackjack games"][channel]["user hands"][user]["hand"].pop(1))
|
|
|
|
|
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"])
|
|
|
|
|
otherHandValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"])
|
|
|
|
|
if handValue > 21:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["busted"] = True
|
|
|
|
|
elif handValue == 21:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["blackjack"] = True
|
|
|
|
|
|
|
|
|
|
if otherHandValue > 21:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["other hand"]["busted"] = True
|
|
|
|
|
elif otherHandValue == 21:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open("resources/games/games.json", "w") as f:
|
|
|
|
|
json.dump(data,f,indent=4)
|
|
|
|
|
|
|
|
|
|
roundDone = True
|
|
|
|
|
|
|
|
|
|
for person in data["blackjack games"][channel]["user hands"].values():
|
|
|
|
|
if person["hit"] == False and person["standing"] == False:
|
|
|
|
|
roundDone = False
|
|
|
|
|
|
|
|
|
|
if person["split"]:
|
|
|
|
|
if person["other hand"]["hit"] == False and person["other 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"])
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" doesn't have enough GwendoBucks")
|
|
|
|
|
return "You don't have enough GwendoBucks",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split 2 different cards")
|
|
|
|
|
return "Your cards need to have the same value to split",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split on round "+data["blackjack games"][channel]["round"])
|
|
|
|
|
return "You can only split on the first round",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" is already standing")
|
|
|
|
|
return "You can't split when you're standing",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" has already hit this round")
|
|
|
|
|
return "You've already hit this round",""
|
|
|
|
|
if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
|
|
|
|
|
hand = data["blackjack games"][channel]["user hands"][user]
|
|
|
|
|
newHand = data["blackjack games"][channel]["user hands"][user]["other hand"]
|
|
|
|
|
handNumber = 0
|
|
|
|
|
otherHand = 2
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split on the 0th round")
|
|
|
|
|
return "You can't split before you see your cards",""
|
|
|
|
|
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:
|
|
|
|
|
bet = hand["bet"]
|
|
|
|
|
if money.checkBalance(user) >= bet:
|
|
|
|
|
money.addMoney(user,-1 * bet)
|
|
|
|
|
with open("resources/games/games.json", "r") as f:
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hand["hit"] = True
|
|
|
|
|
newHand["hit"] = True
|
|
|
|
|
|
|
|
|
|
newHand = {
|
|
|
|
|
"hand":[],"bet":0,"standing":False,"busted":False,
|
|
|
|
|
"blackjack":False,"hit":True,"doubled":False}
|
|
|
|
|
|
|
|
|
|
newHand["bet"] = hand["bet"]
|
|
|
|
|
|
|
|
|
|
newHand["hand"].append(hand["hand"].pop(1))
|
|
|
|
|
newHand["hand"].append(drawCard(channel))
|
|
|
|
|
hand["hand"].append(drawCard(channel))
|
|
|
|
|
|
|
|
|
|
handValue = calcHandValue(hand["hand"])
|
|
|
|
|
otherHandValue = calcHandValue(newHand["hand"])
|
|
|
|
|
if handValue > 21:
|
|
|
|
|
hand["busted"] = True
|
|
|
|
|
elif handValue == 21:
|
|
|
|
|
hand["blackjack"] = True
|
|
|
|
|
|
|
|
|
|
if otherHandValue > 21:
|
|
|
|
|
newHand["busted"] = True
|
|
|
|
|
elif otherHandValue == 21:
|
|
|
|
|
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:
|
|
|
|
|
json.dump(data,f,indent=4)
|
|
|
|
|
|
|
|
|
|
roundDone = True
|
|
|
|
|
|
|
|
|
|
for person in data["blackjack games"][channel]["user hands"].values():
|
|
|
|
|
if person["hit"] == False and person["standing"] == False:
|
|
|
|
|
roundDone = False
|
|
|
|
|
|
|
|
|
|
if person["split"] > 0:
|
|
|
|
|
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == 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"])
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" doesn't have enough GwendoBucks")
|
|
|
|
|
return "You don't have enough GwendoBucks",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split 2 different cards")
|
|
|
|
|
return "Your cards need to have the same value to split",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split later than they could")
|
|
|
|
|
return "You can only split on the first round",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" is already standing")
|
|
|
|
|
return "You can't split when you're standing",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" has already hit this round")
|
|
|
|
|
return "You've already hit this round",""
|
|
|
|
|
else:
|
|
|
|
|
logThis(user+" tried to split on the 0th round")
|
|
|
|
|
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
|
|
|
|
|
def blackjackPlayerDrawHand(channel,user,bet):
|
|
|
|
@ -491,15 +612,11 @@ def blackjackPlayerDrawHand(channel,user,bet):
|
|
|
|
|
if handValue == 21:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
|
|
|
|
|
"bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True,
|
|
|
|
|
"doubled":False,"split":False,"other hand":{
|
|
|
|
|
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
|
|
|
|
|
"doubled":False}}
|
|
|
|
|
"doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
|
|
|
|
|
else:
|
|
|
|
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
|
|
|
|
|
"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True,
|
|
|
|
|
"doubled":False,"split":False,"other hand":{
|
|
|
|
|
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
|
|
|
|
|
"doubled":False}}
|
|
|
|
|
"doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
|
|
|
|
|
|
|
|
|
|
with open("resources/games/games.json", "w") as f:
|
|
|
|
|
json.dump(data,f,indent=4)
|
|
|
|
@ -560,69 +677,32 @@ def blackjackFinish(channel):
|
|
|
|
|
data = json.load(f)
|
|
|
|
|
|
|
|
|
|
dealerValue = calcHandValue(data["blackjack games"][channel]["dealer hand"])
|
|
|
|
|
reason = ""
|
|
|
|
|
dealerBlackjack = data["blackjack games"][channel]["dealer blackjack"]
|
|
|
|
|
dealerBusted = data["blackjack games"][channel]["dealer busted"]
|
|
|
|
|
|
|
|
|
|
for user in data["blackjack games"][channel]["user hands"]:
|
|
|
|
|
winnings = -1 * data["blackjack games"][channel]["user hands"][user]["bet"]
|
|
|
|
|
if data["blackjack games"][channel]["user hands"][user]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
|
|
|
|
|
reason = "(blackjack)"
|
|
|
|
|
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["bet"])
|
|
|
|
|
elif data["blackjack games"][channel]["dealer blackjack"]:
|
|
|
|
|
reason += "(dealer blackjack)"
|
|
|
|
|
elif data["blackjack games"][channel]["user hands"][user]["busted"]:
|
|
|
|
|
reason = "(busted)"
|
|
|
|
|
else:
|
|
|
|
|
if data["blackjack games"][channel]["dealer busted"]:
|
|
|
|
|
reason = "(dealer busted)"
|
|
|
|
|
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
|
|
|
|
|
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) > dealerValue:
|
|
|
|
|
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
|
|
|
|
|
reason = "(highest value)"
|
|
|
|
|
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) == dealerValue:
|
|
|
|
|
reason = "(pushed)"
|
|
|
|
|
winnings += data["blackjack games"][channel]["user hands"][user]["bet"]
|
|
|
|
|
else:
|
|
|
|
|
reason = "(highest value)"
|
|
|
|
|
try:
|
|
|
|
|
for user in data["blackjack games"][channel]["user hands"]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if data["blackjack games"][channel]["user hands"][user]["split"]:
|
|
|
|
|
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:
|
|
|
|
|
reason += "(blackjack)"
|
|
|
|
|
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"])
|
|
|
|
|
elif data["blackjack games"][channel]["dealer blackjack"]:
|
|
|
|
|
reason += "(dealer blackjack)"
|
|
|
|
|
elif data["blackjack games"][channel]["user hands"][user]["other hand"]["busted"]:
|
|
|
|
|
reason += "(busted)"
|
|
|
|
|
else:
|
|
|
|
|
if data["blackjack games"][channel]["dealer busted"]:
|
|
|
|
|
reason += "(dealer busted)"
|
|
|
|
|
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
|
|
|
|
|
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"]) > dealerValue:
|
|
|
|
|
reason += "(highest value)"
|
|
|
|
|
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
|
|
|
|
|
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"]) == dealerValue:
|
|
|
|
|
reason += "(pushed)"
|
|
|
|
|
winnings += data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
|
|
|
|
|
try:
|
|
|
|
|
winnings, netWinnings, reason = calcWinnings(data["blackjack games"][channel]["user hands"][user],dealerValue,True,dealerBlackjack,dealerBusted)
|
|
|
|
|
except:
|
|
|
|
|
logThis("Error calculating winnings for "+str(user)+" (error code 1312)")
|
|
|
|
|
|
|
|
|
|
if winnings < 0:
|
|
|
|
|
if winnings == -1:
|
|
|
|
|
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBuck "+reason+"\n"
|
|
|
|
|
else:
|
|
|
|
|
reason += "(highest value)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if winnings < 0:
|
|
|
|
|
if winnings == -1:
|
|
|
|
|
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBuck "+reason+"\n"
|
|
|
|
|
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBucks "+reason+"\n"
|
|
|
|
|
else:
|
|
|
|
|
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBucks "+reason+"\n"
|
|
|
|
|
else:
|
|
|
|
|
if winnings == 1:
|
|
|
|
|
finalWinnings += user+" won "+str(winnings)+" GwendoBuck "+reason+"\n"
|
|
|
|
|
else:
|
|
|
|
|
finalWinnings += user+" won "+str(winnings)+" GwendoBucks "+reason+"\n"
|
|
|
|
|
|
|
|
|
|
netWinnings = winnings + data["blackjack games"][channel]["user hands"][user]["bet"] + data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
|
|
|
|
|
if winnings == 1:
|
|
|
|
|
finalWinnings += user+" won "+str(winnings)+" GwendoBuck "+reason+"\n"
|
|
|
|
|
else:
|
|
|
|
|
finalWinnings += user+" won "+str(winnings)+" GwendoBucks "+reason+"\n"
|
|
|
|
|
|
|
|
|
|
money.addMoney(user,netWinnings)
|
|
|
|
|
money.addMoney(user,netWinnings)
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
logThis("Error calculating winnings (error code 1311)")
|
|
|
|
|
|
|
|
|
|
with open("resources/games/games.json", "r") as f:
|
|
|
|
|
data = json.load(f)
|
|
|
|
@ -633,3 +713,56 @@ def blackjackFinish(channel):
|
|
|
|
|
json.dump(data,f,indent=4)
|
|
|
|
|
|
|
|
|
|
return finalWinnings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def calcWinnings(hand, dealerValue, topLevel, dealerBlackjack, dealerBusted):
|
|
|
|
|
logThis("Calculating winnings")
|
|
|
|
|
reason = ""
|
|
|
|
|
bet = hand["bet"]
|
|
|
|
|
winnings = -1 * bet
|
|
|
|
|
netWinnings = 0
|
|
|
|
|
handValue = calcHandValue(hand["hand"])
|
|
|
|
|
|
|
|
|
|
if hand["blackjack"] and dealerBlackjack == False:
|
|
|
|
|
reason += "(blackjack)"
|
|
|
|
|
winnings += math.floor(2.5 * bet)
|
|
|
|
|
netWinnings += math.floor(2.5 * bet)
|
|
|
|
|
elif dealerBlackjack:
|
|
|
|
|
reason += "(dealer blackjack)"
|
|
|
|
|
elif hand["busted"]:
|
|
|
|
|
reason += "(busted)"
|
|
|
|
|
else:
|
|
|
|
|
if dealerBusted:
|
|
|
|
|
reason = "(dealer busted)"
|
|
|
|
|
winnings += 2 * bet
|
|
|
|
|
netWinnings += 2 * bet
|
|
|
|
|
elif handValue > dealerValue:
|
|
|
|
|
winnings += 2 * bet
|
|
|
|
|
netWinnings += 2 * bet
|
|
|
|
|
reason = "(highest value)"
|
|
|
|
|
elif handValue == dealerValue:
|
|
|
|
|
reason = "(pushed)"
|
|
|
|
|
winnings += bet
|
|
|
|
|
netWinnings += bet
|
|
|
|
|
else:
|
|
|
|
|
reason = "(highest value)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if topLevel:
|
|
|
|
|
if hand["split"] >= 1:
|
|
|
|
|
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["other hand"],dealerValue,False,dealerBlackjack,dealerBusted)
|
|
|
|
|
winnings += winningsTemp
|
|
|
|
|
netWinnings += netWinningsTemp
|
|
|
|
|
reason += reasonTemp
|
|
|
|
|
if hand["split"] >= 2:
|
|
|
|
|
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["third hand"],dealerValue,False,dealerBlackjack,dealerBusted)
|
|
|
|
|
winnings += winningsTemp
|
|
|
|
|
netWinnings += netWinningsTemp
|
|
|
|
|
reason += reasonTemp
|
|
|
|
|
if hand["split"] >= 3:
|
|
|
|
|
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["fourth hand"],dealerValue,False,dealerBlackjack,dealerBusted)
|
|
|
|
|
winnings += winningsTemp
|
|
|
|
|
netWinnings += netWinningsTemp
|
|
|
|
|
reason += reasonTemp
|
|
|
|
|
|
|
|
|
|
return winnings, netWinnings, reason
|