Added doubling in blackjack

This commit is contained in:
NikolajDanger
2020-07-28 12:00:35 +02:00
parent e681cb4ed5
commit 71fcf80eab
4 changed files with 43 additions and 2 deletions

View File

@ -377,6 +377,11 @@ async def on_message(message):
await message.add_reaction("👍")
else:
await message.channel.send(response)
if message.content.lower().startswith("!blackjack double"):
response = funcs.blackjackDouble(str(message.channel),message.author.name)
await message.channel.send(response)
# Is a bit sassy sometimes

View File

@ -6,6 +6,6 @@ from .lookup import spellFunc, monsterFunc
from .other import nameGen, tavernGen, movieFunc
from .games import triviaStart, triviaOtherThing, triviaCountPoints, checkBalance, addMoney, giveMoney, shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackStand, blackjackHit
from .games import triviaStart, triviaOtherThing, triviaCountPoints, checkBalance, addMoney, giveMoney, shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackStand, blackjackHit,blackjackDouble
from .roll import roll_dice

View File

@ -1,3 +1,3 @@
from .money import checkBalance, giveMoney, addMoney
from .trivia import triviaCountPoints, triviaStart, triviaOtherThing
from .blackjack import shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand
from .blackjack import shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble

View File

@ -176,6 +176,42 @@ def blackjackHit(channel,user):
logThis(user+" tried to hit on the first round")
return "You can't hit before you see your cards"
def blackjackDouble(channel,user):
with open("resources/games/games.json", "r") as f:
data = json.load(f)
if data["blackjack games"][channel]["user hands"][user]["hit"] == False:
if data["blackjack games"][channel]["user hands"][user]["standing"] == False:
bet = data["blackjack games"][channel]["user hands"][user]["bet"]
if money.checkBalance(user) >= bet:
money.addMoney(user,-1 * bet)
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]["standing"] = True
data["blackjack games"][channel]["user hands"][user]["bet"] += bet
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"])
if handValue > 21:
data["blackjack games"][channel]["user hands"][user]["busted"] = True
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)
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+" is already standing")
return "You can't hit when you're standing"
else:
logThis(user+" has already hit this round")
return "You've already hit this round"
def blackjackStand(channel,user):
with open("resources/games/games.json", "r") as f:
data = json.load(f)