🔧 tweaked doubling and rounds
This commit is contained in:
@ -93,9 +93,10 @@ def blackjackContinue(channel):
|
|||||||
|
|
||||||
done = False
|
done = False
|
||||||
|
|
||||||
if data["blackjack games"][channel]["open for bets"]:
|
data["blackjack games"][channel]["round"] += 1
|
||||||
data["blackjack games"][channel]["open for bets"] = False
|
|
||||||
|
|
||||||
|
with open("resources/games/games.json", "w") as f:
|
||||||
|
json.dump(data,f,indent=4)
|
||||||
|
|
||||||
allStanding = True
|
allStanding = True
|
||||||
preAllStanding = True
|
preAllStanding = True
|
||||||
@ -118,7 +119,7 @@ def blackjackContinue(channel):
|
|||||||
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
||||||
allStanding = False
|
allStanding = False
|
||||||
|
|
||||||
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) >= 21:
|
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) >= 21 or data["blackjack games"][channel]["user hands"][user]["doubled"]:
|
||||||
data["blackjack games"][channel]["user hands"][user]["standing"] = True
|
data["blackjack games"][channel]["user hands"][user]["standing"] = True
|
||||||
else:
|
else:
|
||||||
preAllStanding = False
|
preAllStanding = False
|
||||||
@ -149,7 +150,7 @@ def blackjackHit(channel,user):
|
|||||||
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]["open for bets"] == False:
|
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]["hit"] == False:
|
||||||
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
||||||
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard())
|
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard())
|
||||||
@ -173,49 +174,59 @@ def blackjackHit(channel,user):
|
|||||||
logThis(user+" has already hit this round")
|
logThis(user+" has already hit this round")
|
||||||
return "You've already hit this round"
|
return "You've already hit this round"
|
||||||
else:
|
else:
|
||||||
logThis(user+" tried to hit on the first round")
|
logThis(user+" tried to hit on the 0th round")
|
||||||
return "You can't hit before you see your cards"
|
return "You can't hit before you see your cards"
|
||||||
|
|
||||||
def blackjackDouble(channel,user):
|
def blackjackDouble(channel,user):
|
||||||
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]["hit"] == False:
|
if data["blackjack games"][channel]["round"] > 0:
|
||||||
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
if data["blackjack games"][channel]["user hands"][user]["hit"] == False:
|
||||||
bet = data["blackjack games"][channel]["user hands"][user]["bet"]
|
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
||||||
if money.checkBalance(user) >= bet:
|
if data["blackjack games"][channel]["round"] == 1:
|
||||||
money.addMoney(user,-1 * bet)
|
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]["hand"].append(drawCard())
|
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard())
|
||||||
data["blackjack games"][channel]["user hands"][user]["hit"] = True
|
data["blackjack games"][channel]["user hands"][user]["hit"] = True
|
||||||
data["blackjack games"][channel]["user hands"][user]["standing"] = True
|
data["blackjack games"][channel]["user hands"][user]["doubled"] = True
|
||||||
data["blackjack games"][channel]["user hands"][user]["bet"] += bet
|
data["blackjack games"][channel]["user hands"][user]["bet"] += bet
|
||||||
|
|
||||||
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"])
|
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"])
|
||||||
|
|
||||||
|
|
||||||
if handValue > 21:
|
if handValue > 21:
|
||||||
data["blackjack games"][channel]["user hands"][user]["busted"] = True
|
data["blackjack games"][channel]["user hands"][user]["busted"] = True
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
return "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet"
|
return "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet"
|
||||||
|
else:
|
||||||
|
logThis(user+" doesn't have enough GwendoBucks")
|
||||||
|
return "You don't have enough GwendoBucks"
|
||||||
|
else:
|
||||||
|
logThis(user+" tried to double on round "+data["blackjack games"][channel]["user hands"][user]["round"])
|
||||||
|
return "You can only double down on the first round"
|
||||||
else:
|
else:
|
||||||
logThis(user+" doesn't have enough GwendoBucks")
|
logThis(user+" is already standing")
|
||||||
return "You don't have enough GwendoBucks"
|
return "You can't hit when you're standing"
|
||||||
else:
|
else:
|
||||||
logThis(user+" is already standing")
|
logThis(user+" has already hit this round")
|
||||||
return "You can't hit when you're standing"
|
return "You've already hit this round"
|
||||||
else:
|
else:
|
||||||
logThis(user+" has already hit this round")
|
logThis(user+" tried to double on the 0th round")
|
||||||
return "You've already hit this round"
|
return "You can't double down before you see your cards"
|
||||||
|
|
||||||
def blackjackStand(channel,user):
|
def blackjackStand(channel,user):
|
||||||
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]["open for bets"] == False:
|
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]["hit"] == False:
|
||||||
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
|
||||||
data["blackjack games"][channel]["user hands"][user]["standing"] = True
|
data["blackjack games"][channel]["user hands"][user]["standing"] = True
|
||||||
@ -242,7 +253,7 @@ def blackjackPlayerDrawHand(channel,user,bet):
|
|||||||
if channel in data["blackjack games"]:
|
if channel in data["blackjack games"]:
|
||||||
if user not in data["blackjack games"][channel]["user hands"]:
|
if user not in data["blackjack games"][channel]["user hands"]:
|
||||||
if len(data["blackjack games"][channel]["user hands"]) < 5:
|
if len(data["blackjack games"][channel]["user hands"]) < 5:
|
||||||
if data["blackjack games"][channel]["open for bets"]:
|
if data["blackjack games"][channel]["round"] == 0:
|
||||||
if bet >= 0:
|
if bet >= 0:
|
||||||
if money.checkBalance(user) >= bet:
|
if money.checkBalance(user) >= bet:
|
||||||
money.addMoney(user,-1 * bet)
|
money.addMoney(user,-1 * bet)
|
||||||
@ -254,9 +265,9 @@ def blackjackPlayerDrawHand(channel,user,bet):
|
|||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
if handValue == 21:
|
if handValue == 21:
|
||||||
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True}
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True,"doubled":False}
|
||||||
else:
|
else:
|
||||||
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True}
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"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)
|
||||||
@ -292,7 +303,7 @@ def blackjackStart(channel:str):
|
|||||||
|
|
||||||
dealerHand = [drawCard(),drawCard()]
|
dealerHand = [drawCard(),drawCard()]
|
||||||
|
|
||||||
data["blackjack games"][channel] = {"dealer hand": dealerHand,"dealer busted":False,"dealer blackjack":False,"user hands": {},"open for bets":True,"all standing":False}
|
data["blackjack games"][channel] = {"dealer hand": dealerHand,"dealer busted":False,"dealer blackjack":False,"user hands": {},"all standing":False,"round":0}
|
||||||
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)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user