✨ Blackjack doesn't wait
This commit is contained in:
72
Gwendolyn.py
72
Gwendolyn.py
@ -38,17 +38,22 @@ async def blackjackLoop(channel,gameRound):
|
|||||||
if allStanding:
|
if allStanding:
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(30)
|
await asyncio.sleep(120)
|
||||||
|
|
||||||
with open("resources/games/games.json", "r") as f:
|
with open("resources/games/games.json", "r") as f:
|
||||||
realRound = json.load(f)["blackjack games"][str(channel)]["round"]
|
data = json.load(f)
|
||||||
|
|
||||||
if gameRound == realRound:
|
if str(channel) in data["blackjack games"]:
|
||||||
if gamedone == False:
|
realRound = data["blackjack games"][str(channel)]["round"]
|
||||||
await blackjackLoop(channel,gameRound+1)
|
|
||||||
|
if gameRound == realRound:
|
||||||
|
if gamedone == False:
|
||||||
|
await blackjackLoop(channel,gameRound+1)
|
||||||
|
else:
|
||||||
|
new_message = blackjackFinish(str(channel))
|
||||||
|
await channel.send(new_message)
|
||||||
else:
|
else:
|
||||||
new_message = blackjackFinish(str(channel))
|
logThis("Ending loop on round "+str(gameRound))
|
||||||
await channel.send(new_message)
|
|
||||||
else:
|
else:
|
||||||
logThis("Ending loop on round "+str(gameRound))
|
logThis("Ending loop on round "+str(gameRound))
|
||||||
|
|
||||||
@ -460,7 +465,7 @@ async def parseCommands(message,content):
|
|||||||
# Hitting
|
# Hitting
|
||||||
elif content.startswith("blackjack hit"):
|
elif content.startswith("blackjack hit"):
|
||||||
if content == "blackjack hit" or content == "blackjack hit ":
|
if content == "blackjack hit" or content == "blackjack hit ":
|
||||||
response = blackjackHit(str(message.channel),message.author.display_name)
|
response= blackjackHit(str(message.channel),message.author.display_name)
|
||||||
else:
|
else:
|
||||||
commands = content.split(" ")
|
commands = content.split(" ")
|
||||||
try:
|
try:
|
||||||
@ -469,39 +474,64 @@ async def parseCommands(message,content):
|
|||||||
handNumber = 0
|
handNumber = 0
|
||||||
response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
|
response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
|
||||||
|
|
||||||
if response == "accept":
|
if response.startswith("accept"):
|
||||||
await message.add_reaction("👍")
|
await message.add_reaction("👍")
|
||||||
|
try:
|
||||||
|
if response[6] == "T":
|
||||||
|
await blackjackLoop(message.channel,int(response[7:])+1)
|
||||||
|
except:
|
||||||
|
logThis("Something fucked up")
|
||||||
|
await message.channel.send("something fucked up")
|
||||||
else:
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
|
|
||||||
# Standing
|
# Standing
|
||||||
elif content.startswith("blackjack stand"):
|
elif content.startswith("blackjack stand"):
|
||||||
response = blackjackStand(str(message.channel),message.author.display_name,0)
|
response = blackjackStand(str(message.channel),message.author.display_name,0)
|
||||||
if response == "accept":
|
|
||||||
|
if response.startswith("accept"):
|
||||||
await message.add_reaction("👍")
|
await message.add_reaction("👍")
|
||||||
|
try:
|
||||||
|
if response[6] == "T":
|
||||||
|
await blackjackLoop(message.channel,int(response[7:])+1)
|
||||||
|
except:
|
||||||
|
logThis("Something fucked up")
|
||||||
|
await message.channel.send("something fucked up")
|
||||||
else:
|
else:
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
# Doubling bet
|
# Doubling bet
|
||||||
elif content.startswith("blackjack double"):
|
elif content.startswith("blackjack double"):
|
||||||
if content == "blackjack hit" or content == "blackjack hit ":
|
commands = content.split(" ")
|
||||||
response = blackjackDouble(str(message.channel),message.author.display_name)
|
try:
|
||||||
else:
|
handNumber = int(commands[2])
|
||||||
commands = content.split(" ")
|
except:
|
||||||
try:
|
handNumber = 0
|
||||||
handNumber = int(commands[2])
|
response, roundDone = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
|
||||||
except:
|
|
||||||
handNumber = 0
|
|
||||||
response = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
|
|
||||||
|
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
|
try:
|
||||||
|
if roundDone[0] == "T":
|
||||||
|
await blackjackLoop(message.channel,int(roundDone[1:])+1)
|
||||||
|
except:
|
||||||
|
logThis("Something fucked up")
|
||||||
|
await message.channel.send("something fucked up")
|
||||||
|
|
||||||
# Splitting hand
|
# Splitting hand
|
||||||
elif content.startswith("blackjack split"):
|
elif content.startswith("blackjack split"):
|
||||||
response = blackjackSplit(str(message.channel),message.author.display_name)
|
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name)
|
||||||
|
|
||||||
await message.channel.send(response)
|
await message.channel.send(response)
|
||||||
|
|
||||||
|
#try:
|
||||||
|
if roundDone[0] == "T":
|
||||||
|
await blackjackLoop(message.channel,int(roundDone[1:])+1)
|
||||||
|
#except:
|
||||||
|
# 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":
|
||||||
with open("resources/games/hilo.txt", "r") as f:
|
with open("resources/games/hilo.txt", "r") as f:
|
||||||
|
@ -180,7 +180,7 @@ def blackjackContinue(channel):
|
|||||||
firstRoundMessage = ". You can also double down with \"!blackjack double\" or split with \"!blackjack split\""
|
firstRoundMessage = ". You can also double down with \"!blackjack double\" or split with \"!blackjack split\""
|
||||||
else:
|
else:
|
||||||
firstRoundMessage = ""
|
firstRoundMessage = ""
|
||||||
return "You have 30 seconds to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done
|
return "You have 2 minutes to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done
|
||||||
|
|
||||||
# When players try to hit
|
# When players try to hit
|
||||||
def blackjackHit(channel,user,handNumber = 0):
|
def blackjackHit(channel,user,handNumber = 0):
|
||||||
@ -225,7 +225,18 @@ def blackjackHit(channel,user,handNumber = 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)
|
||||||
|
|
||||||
return "accept"
|
response = "accept"
|
||||||
|
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 response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
|
||||||
else:
|
else:
|
||||||
logThis(user+" is already standing")
|
logThis(user+" is already standing")
|
||||||
return "You can't hit when you're standing"
|
return "You can't hit when you're standing"
|
||||||
@ -259,10 +270,10 @@ def blackjackDouble(channel,user,handNumber = 0):
|
|||||||
otherHand = True
|
otherHand = True
|
||||||
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
|
correctRound = 2
|
||||||
|
|
||||||
|
|
||||||
@ -295,22 +306,33 @@ def blackjackDouble(channel,user,handNumber = 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)
|
||||||
|
|
||||||
return "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet and drawing another card."
|
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 "Adding another "+str(bet)+" GwendoBucks to "+user+"'s bet and drawing another card.",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")
|
||||||
return "You don't have enough GwendoBucks"
|
return "You don't have enough GwendoBucks",""
|
||||||
else:
|
else:
|
||||||
logThis(user+" tried to double on round "+str(data["blackjack games"][channel]["round"]))
|
logThis(user+" tried to double on round "+str(data["blackjack games"][channel]["round"]))
|
||||||
return "You can only double down on the first round"
|
return "You can only double down on the first round",""
|
||||||
else:
|
else:
|
||||||
logThis(user+" is already standing")
|
logThis(user+" is already standing")
|
||||||
return "You can't double when you're standing"
|
return "You can't double when you're standing",""
|
||||||
else:
|
else:
|
||||||
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 double on the 0th round")
|
logThis(user+" tried to double on the 0th round")
|
||||||
return "You can't double down before you see your cards"
|
return "You can't double down before you see your cards",""
|
||||||
|
|
||||||
# When players try to stand
|
# When players try to stand
|
||||||
def blackjackStand(channel,user,handNumber = 0):
|
def blackjackStand(channel,user,handNumber = 0):
|
||||||
@ -326,7 +348,18 @@ def blackjackStand(channel,user,handNumber = 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)
|
||||||
|
|
||||||
return "accept"
|
response = "accept"
|
||||||
|
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 response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
|
||||||
else:
|
else:
|
||||||
logThis(user+" is already standing")
|
logThis(user+" is already standing")
|
||||||
return "You're already standing"
|
return "You're already standing"
|
||||||
@ -385,25 +418,35 @@ def blackjackSplit(channel,user):
|
|||||||
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 "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."
|
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:
|
else:
|
||||||
logThis(user+" doesn't have enough GwendoBucks")
|
logThis(user+" doesn't have enough GwendoBucks")
|
||||||
return "You don't have enough GwendoBucks"
|
return "You don't have enough GwendoBucks",""
|
||||||
else:
|
else:
|
||||||
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 on round "+data["blackjack games"][channel]["round"])
|
||||||
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")
|
||||||
return "You can't split when you're standing"
|
return "You can't split when you're standing",""
|
||||||
else:
|
else:
|
||||||
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 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",""
|
||||||
|
|
||||||
# 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):
|
||||||
|
Reference in New Issue
Block a user