🐛 Players can't bet negative amounts
This commit is contained in:
@ -195,28 +195,32 @@ def blackjackPlayerDrawHand(channel,user,bet):
|
|||||||
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]["open for bets"]:
|
||||||
if money.checkBalance(user) >= bet:
|
if bet >= 0:
|
||||||
money.addMoney(user,-1 * bet)
|
if money.checkBalance(user) >= bet:
|
||||||
playerHand = [drawCard(),drawCard()]
|
money.addMoney(user,-1 * bet)
|
||||||
|
playerHand = [drawCard(),drawCard()]
|
||||||
|
|
||||||
handValue = calcHandValue(playerHand)
|
handValue = calcHandValue(playerHand)
|
||||||
|
|
||||||
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 handValue == 21:
|
if handValue == 21:
|
||||||
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":True,"busted":False,"blackjack":True,"hit":True}
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":True,"busted":False,"blackjack":True,"hit":True}
|
||||||
|
else:
|
||||||
|
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True}
|
||||||
|
|
||||||
|
with open("resources/games/games.json", "w") as f:
|
||||||
|
json.dump(data,f,indent=4)
|
||||||
|
|
||||||
|
logThis(user+" entered the game")
|
||||||
|
return user+" entered the game"
|
||||||
else:
|
else:
|
||||||
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True}
|
logThis(user+" doesn't have enough GwendoBucks")
|
||||||
|
return "You don't have enough GwendoBucks to place that bet"
|
||||||
with open("resources/games/games.json", "w") as f:
|
|
||||||
json.dump(data,f,indent=4)
|
|
||||||
|
|
||||||
logThis(user+" entered the game")
|
|
||||||
return user+" entered the game"
|
|
||||||
else:
|
else:
|
||||||
logThis(user+" doesn't have enough GwendoBucks")
|
logThis(user+" tried to bet a negative amount")
|
||||||
return "You don't have enough GwendoBucks to place that bet"
|
return "You can't bet a negative amount"
|
||||||
else:
|
else:
|
||||||
logThis("The table is no longer open for bets")
|
logThis("The table is no longer open for bets")
|
||||||
return "The table is no longer open for bets"
|
return "The table is no longer open for bets"
|
||||||
|
Reference in New Issue
Block a user