Merge branch 'master' of https://github.com/NikolajDanger/Gwendolyn
This commit is contained in:
561
Gwendolyn.py
561
Gwendolyn.py
@ -7,10 +7,12 @@ import codecs
|
||||
import string
|
||||
import json
|
||||
import random
|
||||
import math
|
||||
#import math
|
||||
import os
|
||||
|
||||
from funcs import *
|
||||
from funcs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, emojiToNumber, fiarReactionTest, deleteGame, stopServer, checkBalance, giveMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI, spellFunc, monsterFunc, nameGen, tavernGen, movieFunc, roll_dice, parseChar, parseRoll, critRoll, parseDestiny
|
||||
|
||||
from gameLoops import fiar, blackjackLoop
|
||||
|
||||
commandPrefix = "!"
|
||||
|
||||
@ -21,204 +23,6 @@ blackjackDecks = 4
|
||||
# Variable for reacting to messages
|
||||
meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"]
|
||||
|
||||
# Runs Hex
|
||||
async def hex(channel,command,user):
|
||||
try:
|
||||
response, showImage, deleteImage, gameDone, gwendoTurn = parseHex(command,str(channel),user)
|
||||
except:
|
||||
logThis("Error parsing command (error code 1510)")
|
||||
|
||||
await channel.send(response)
|
||||
logThis(response,str(channel))
|
||||
if showImage:
|
||||
if deleteImage:
|
||||
try:
|
||||
oldImage = await deleteMessage("hex"+str(channel),channel)
|
||||
except:
|
||||
logThis("Error deleting old image (error code 1501)")
|
||||
oldImage = await channel.send(file = discord.File("resources/games/hexBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
if gwendoTurn:
|
||||
try:
|
||||
response, showImage, deleteImage, gameDone, gwendoTurn = hexAI(str(channel))
|
||||
except:
|
||||
logThis("AI error (error code 1420)")
|
||||
await channel.send(response)
|
||||
logThis(response,str(channel))
|
||||
if showImage:
|
||||
if deleteImage:
|
||||
await oldImage.delete()
|
||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
try:
|
||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||
for reaction in reactions:
|
||||
await oldImage.add_reaction(reaction)
|
||||
|
||||
except:
|
||||
logThis("Image deleted before I could react to all of them")
|
||||
|
||||
else:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
try:
|
||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||
for reaction in reactions:
|
||||
await oldImage.add_reaction(reaction)
|
||||
except:
|
||||
logThis("Image deleted before I could react to all of them")
|
||||
# else:
|
||||
# with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
# f.write(str(oldImage.id))
|
||||
|
||||
if gameDone:
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
try:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
|
||||
oldImage = await channel.fetch_message(int(f.read()))
|
||||
|
||||
await oldImage.delete()
|
||||
except:
|
||||
logThis("The old image was already deleted")
|
||||
|
||||
winner = data["4 in a row games"][str(channel)]["winner"]
|
||||
if winner != 0:
|
||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),20)
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
deleteGame("4 in a row games",str(channel))
|
||||
|
||||
|
||||
# Runs Four in a Row
|
||||
async def fiar(channel,command,user):
|
||||
try:
|
||||
response, showImage, deleteImage, gameDone, gwendoTurn = parseFourInARow(command,str(channel),user)
|
||||
except:
|
||||
logThis("Error parsing command (error code 1410)")
|
||||
|
||||
await channel.send(response)
|
||||
logThis(response,str(channel))
|
||||
if showImage:
|
||||
if deleteImage:
|
||||
try:
|
||||
oldImage = await deleteMessage("fourInARow"+str(channel),channel)
|
||||
except:
|
||||
logThis("Error deleting message (error code 1401)")
|
||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
if gwendoTurn:
|
||||
try:
|
||||
response, showImage, deleteImage, gameDone, gwendoTurn = fourInARowAI(str(channel))
|
||||
except:
|
||||
logThis("AI error (error code 1420)")
|
||||
await channel.send(response)
|
||||
logThis(response,str(channel))
|
||||
if showImage:
|
||||
if deleteImage:
|
||||
await oldImage.delete()
|
||||
oldImage = await channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(channel)+".png"))
|
||||
if gameDone == False:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
try:
|
||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||
for reaction in reactions:
|
||||
await oldImage.add_reaction(reaction)
|
||||
|
||||
except:
|
||||
logThis("Image deleted before I could react to all of them")
|
||||
|
||||
else:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
try:
|
||||
reactions = ["1️⃣","2️⃣","3️⃣","4️⃣","5️⃣","6️⃣","7️⃣"]
|
||||
for reaction in reactions:
|
||||
await oldImage.add_reaction(reaction)
|
||||
except:
|
||||
logThis("Image deleted before I could react to all of them")
|
||||
# else:
|
||||
# with open("resources/games/oldImages/fourInARow"+str(channel), "w") as f:
|
||||
# f.write(str(oldImage.id))
|
||||
|
||||
if gameDone:
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
try:
|
||||
with open("resources/games/oldImages/fourInARow"+str(channel), "r") as f:
|
||||
oldImage = await channel.fetch_message(int(f.read()))
|
||||
|
||||
await oldImage.delete()
|
||||
except:
|
||||
logThis("The old image was already deleted")
|
||||
|
||||
winner = data["4 in a row games"][str(channel)]["winner"]
|
||||
if winner != 0:
|
||||
addMoney(data["4 in a row games"][str(channel)]["players"][winner-1].lower(),20)
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
deleteGame("4 in a row games",str(channel))
|
||||
|
||||
# Deletes a message
|
||||
async def deleteMessage(imageLocation,channel):
|
||||
try:
|
||||
logThis("Finding old image")
|
||||
with open("resources/games/oldImages/"+imageLocation, "r") as f:
|
||||
oldImage = await channel.fetch_message(int(f.read()))
|
||||
logThis("Deleting old image")
|
||||
await oldImage.delete()
|
||||
except:
|
||||
oldImage = ""
|
||||
|
||||
return oldImage
|
||||
|
||||
# Loop of game rounds
|
||||
async def blackjackLoop(channel,gameRound,gameID):
|
||||
logThis("Loop "+str(gameRound),str(channel))
|
||||
|
||||
with open("resources/games/oldImages/blackjack"+str(channel), "r") as f:
|
||||
oldImage = await channel.fetch_message(int(f.read()))
|
||||
|
||||
new_message, allStanding, gamedone = blackjackContinue(str(channel))
|
||||
if new_message != "":
|
||||
logThis(new_message,str(channel))
|
||||
await channel.send(new_message)
|
||||
if gamedone == False:
|
||||
await oldImage.delete()
|
||||
oldImage = await channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
|
||||
with open("resources/games/oldImages/blackjack"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
if allStanding:
|
||||
await asyncio.sleep(5)
|
||||
else:
|
||||
await asyncio.sleep(120)
|
||||
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if str(channel) in data["blackjack games"]:
|
||||
realRound = data["blackjack games"][str(channel)]["round"]
|
||||
realGameID = data["blackjack games"][str(channel)]["id"]
|
||||
|
||||
if gameRound == realRound and realGameID == gameID:
|
||||
if gamedone == False:
|
||||
logThis("Loop "+str(gameRound)+" calling blackjackLoop()",str(channel))
|
||||
await blackjackLoop(channel,gameRound+1,gameID)
|
||||
else:
|
||||
new_message = blackjackFinish(str(channel))
|
||||
await channel.send(new_message)
|
||||
else:
|
||||
logThis("Ending loop on round "+str(gameRound),str(channel))
|
||||
else:
|
||||
logThis("Ending loop on round "+str(gameRound),str(channel))
|
||||
|
||||
async def parseCommands(message,content):
|
||||
# Sends the contents of a help file, as specified by the message.
|
||||
if content.startswith("help"):
|
||||
@ -246,7 +50,7 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 100)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 100)")
|
||||
|
||||
|
||||
# Logs whatever you write in the message
|
||||
elif content.startswith("log "):
|
||||
logThis(content.replace("log ",""),str(message.channel))
|
||||
@ -289,7 +93,12 @@ async def parseCommands(message,content):
|
||||
# Looks up a spell with the spellFunc function from funcs/lookup/lookuppy
|
||||
elif content.startswith("spell "):
|
||||
try:
|
||||
await message.channel.send(spellFunc(cap(content.replace("spell",""))))
|
||||
spell = spellFunc(cap(content.replace("spell","")))
|
||||
if len(spell) > 2000:
|
||||
await message.channel.send(spell[:2000])
|
||||
await message.channel.send(spell[2000:])
|
||||
else:
|
||||
await message.channel.send(spell)
|
||||
except:
|
||||
logThis("Something fucked up (error code 500)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 500)")
|
||||
@ -355,7 +164,8 @@ async def parseCommands(message,content):
|
||||
# funcs/gwendolynpy
|
||||
elif content.startswith("image"):
|
||||
try:
|
||||
await message.channel.send(imageFunc())
|
||||
randomImage = imageFunc()
|
||||
await message.channel.send(randomImage)
|
||||
except:
|
||||
logThis("Something fucked up (error code 700)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 700)")
|
||||
@ -369,10 +179,13 @@ async def parseCommands(message,content):
|
||||
if title == "error":
|
||||
await message.channel.send("An error occurred. Try again (error code "+plot+")")
|
||||
else:
|
||||
embed = discord.Embed(title=title, description=plot, color=0x24ec19)
|
||||
embed.set_thumbnail(url=cover)
|
||||
embed.add_field(name="Cast", value=cast,inline = True)
|
||||
await message.channel.send(embed = embed)
|
||||
try:
|
||||
embed = discord.Embed(title=title, description=plot, color=0x24ec19)
|
||||
embed.set_thumbnail(url=cover)
|
||||
embed.add_field(name="Cast", value=cast,inline = True)
|
||||
await message.channel.send(embed = embed)
|
||||
except:
|
||||
logThis("Error embedding (error code 805)")
|
||||
except:
|
||||
logThis("Something fucked up (error code 800)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 800)")
|
||||
@ -414,7 +227,7 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 910)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 910)")
|
||||
|
||||
|
||||
# Deals with Destiny Points and stuff
|
||||
elif content.startswith("swd"):
|
||||
try:
|
||||
@ -431,7 +244,7 @@ async def parseCommands(message,content):
|
||||
elif content.startswith("swcrit"):
|
||||
try:
|
||||
command = content.replace("swcrit","").replace(" ","").replace("+","")
|
||||
|
||||
|
||||
if command == "":
|
||||
command = 0
|
||||
|
||||
@ -449,7 +262,7 @@ async def parseCommands(message,content):
|
||||
await message.channel.send("Something fucked up (error code 930)")
|
||||
|
||||
# Accesses and changes character sheet data with the parseChar function
|
||||
# from funcs/swfuncs/swchar.py
|
||||
# from funcs/swfuncs/swchar.py
|
||||
elif content.startswith("swchar") or content.startswith("sw"):
|
||||
try:
|
||||
command = string.capwords(content.replace("swchar","").replace("sw","").replace("+","+ ").replace("-","- ").replace(",",", "))
|
||||
@ -483,7 +296,7 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 1000)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 1000)")
|
||||
|
||||
|
||||
|
||||
# Runs a trivia game
|
||||
elif content.startswith("trivia"):
|
||||
@ -494,7 +307,7 @@ async def parseCommands(message,content):
|
||||
results = "**"+question+"**\n"
|
||||
for answer in range(len(answers)):
|
||||
results += chr(answer+97) + ") "+answers[answer]+"\n"
|
||||
|
||||
|
||||
await message.channel.send(results)
|
||||
|
||||
await asyncio.sleep(60)
|
||||
@ -507,7 +320,7 @@ async def parseCommands(message,content):
|
||||
await message.channel.send("Time's up The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck")
|
||||
else:
|
||||
await message.channel.send(question)
|
||||
|
||||
|
||||
elif content.startswith("trivia "):
|
||||
command = content.replace("trivia ","")
|
||||
response = triviaAnswer(message.author.display_name.lower(),str(message.channel),command)
|
||||
@ -521,7 +334,7 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 1100)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 1100)")
|
||||
|
||||
|
||||
|
||||
# Checks your GwendoBucks balance
|
||||
elif content.startswith("balance"):
|
||||
@ -535,7 +348,7 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 1210)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 1210)")
|
||||
|
||||
|
||||
# Gives money to other player
|
||||
elif content.startswith("give "):
|
||||
try:
|
||||
@ -555,189 +368,191 @@ async def parseCommands(message,content):
|
||||
except:
|
||||
logThis("Something fucked up (error code 1220)",str(message.channel))
|
||||
await message.channel.send("Something fucked up (error code 1220)")
|
||||
|
||||
|
||||
# Runs a game of Blackjack
|
||||
elif content.startswith("blackjack"):
|
||||
try:
|
||||
# Starts the game
|
||||
if content == "blackjack" or content == "blackjack ":
|
||||
cardsLeft = 0
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
||||
for _ in f:
|
||||
cardsLeft += 1
|
||||
|
||||
# Shuffles if not enough cards
|
||||
if cardsLeft < blackjackMinCards:
|
||||
blackjackShuffle(blackjackDecks,str(message.channel))
|
||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
||||
await message.channel.send("Shuffling the deck...")
|
||||
|
||||
new_message = blackjackStart(str(message.channel))
|
||||
if new_message == "started":
|
||||
#try:
|
||||
# Starts the game
|
||||
if content == "blackjack" or content == "blackjack ":
|
||||
cardsLeft = 0
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
||||
for _ in f:
|
||||
cardsLeft += 1
|
||||
|
||||
new_message = "Blackjack game started. Use \""+commandPrefix+"blackjack bet [amount]\" to enter the game within the next 30 seconds."
|
||||
# Shuffles if not enough cards
|
||||
if cardsLeft < blackjackMinCards:
|
||||
blackjackShuffle(blackjackDecks,str(message.channel))
|
||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
||||
await message.channel.send("Shuffling the deck...")
|
||||
|
||||
new_message = blackjackStart(str(message.channel))
|
||||
if new_message == "started":
|
||||
|
||||
new_message = "Blackjack game started. Use \""+commandPrefix+"blackjack bet [amount]\" to enter the game within the next 30 seconds."
|
||||
await message.channel.send(new_message)
|
||||
oldImage = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel)+".png"))
|
||||
|
||||
with open("resources/games/oldImages/blackjack"+str(message.channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
|
||||
await asyncio.sleep(30)
|
||||
|
||||
gamedone = False
|
||||
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
if len(data["blackjack games"][str(message.channel)]["user hands"]) == 0:
|
||||
gamedone = True
|
||||
await message.channel.send("No one entered the game. Ending the game.")
|
||||
gameID = data["blackjack games"][str(message.channel)]["id"]
|
||||
|
||||
# Loop of game rounds
|
||||
if gamedone == False:
|
||||
logThis("!blackjack calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,1,gameID)
|
||||
else:
|
||||
new_message = blackjackFinish(str(message.channel))
|
||||
await message.channel.send(new_message)
|
||||
oldImage = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel)+".png"))
|
||||
else:
|
||||
await message.channel.send(new_message)
|
||||
|
||||
with open("resources/games/oldImages/blackjack"+str(message.channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
# Entering game and placing bet
|
||||
elif content.startswith("blackjack bet"):
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
amount = int(commands[2])
|
||||
except:
|
||||
logThis("I didn't understand that",str(message.channel))
|
||||
response = "I didn't understand that"
|
||||
else:
|
||||
response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
|
||||
await message.channel.send(response)
|
||||
|
||||
await asyncio.sleep(30)
|
||||
|
||||
gamedone = False
|
||||
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
data = json.load(f)
|
||||
if len(data["blackjack games"][str(message.channel)]["user hands"]) == 0:
|
||||
gamedone = True
|
||||
await message.channel.send("No one entered the game. Ending the game.")
|
||||
gameID = data["blackjack games"][str(message.channel)]["id"]
|
||||
|
||||
# Loop of game rounds
|
||||
if gamedone == False:
|
||||
logThis("!blackjack calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,1,gameID)
|
||||
else:
|
||||
new_message = blackjackFinish(str(message.channel))
|
||||
await message.channel.send(new_message)
|
||||
else:
|
||||
await message.channel.send(new_message)
|
||||
|
||||
# Entering game and placing bet
|
||||
elif content.startswith("blackjack bet"):
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
amount = int(commands[2])
|
||||
except:
|
||||
logThis("I didn't understand that",str(message.channel))
|
||||
response = "I didn't understand that"
|
||||
else:
|
||||
response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
|
||||
await message.channel.send(response)
|
||||
|
||||
# Hitting
|
||||
elif content.startswith("blackjack hit"):
|
||||
if content == "blackjack hit" or content == "blackjack hit ":
|
||||
response = blackjackHit(str(message.channel),message.author.display_name)
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await message.add_reaction("👍")
|
||||
try:
|
||||
if response[6] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Hit calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up")
|
||||
await message.channel.send("something fucked up",str(message.channel))
|
||||
else:
|
||||
await message.channel.send(response)
|
||||
|
||||
|
||||
# Standing
|
||||
elif content.startswith("blackjack stand"):
|
||||
if content == "blackjack hit" or content == "blackjack hit ":
|
||||
response = blackjackStand(str(message.channel),message.author.display_name)
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response = blackjackStand(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await message.add_reaction("👍")
|
||||
try:
|
||||
if response[6] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Stand calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up",str(message.channel))
|
||||
await message.channel.send("something fucked up")
|
||||
else:
|
||||
await message.channel.send(response)
|
||||
|
||||
# Doubling bet
|
||||
elif content.startswith("blackjack double"):
|
||||
# Hitting
|
||||
elif content.startswith("blackjack hit"):
|
||||
if content == "blackjack hit" or content == "blackjack hit ":
|
||||
response = blackjackHit(str(message.channel),message.author.display_name)
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response, roundDone = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
await message.channel.send(response)
|
||||
response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await message.add_reaction("👍")
|
||||
try:
|
||||
if roundDone[0] == "T":
|
||||
if response[6] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Double calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
||||
logThis("Hit calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up",str(message.channel))
|
||||
else:
|
||||
await message.channel.send(response)
|
||||
|
||||
|
||||
# Standing
|
||||
elif content.startswith("blackjack stand"):
|
||||
if content == "blackjack hit" or content == "blackjack hit ":
|
||||
response = blackjackStand(str(message.channel),message.author.display_name)
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response = blackjackStand(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await message.add_reaction("👍")
|
||||
try:
|
||||
if response[6] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Stand calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(response[7:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up",str(message.channel))
|
||||
await message.channel.send("something fucked up")
|
||||
|
||||
# Splitting hand
|
||||
elif content.startswith("blackjack split"):
|
||||
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name)
|
||||
|
||||
else:
|
||||
await message.channel.send(response)
|
||||
|
||||
#try:
|
||||
# Doubling bet
|
||||
elif content.startswith("blackjack double"):
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response, roundDone = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
await message.channel.send(response)
|
||||
|
||||
try:
|
||||
if roundDone[0] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Double calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up",str(message.channel))
|
||||
|
||||
# Splitting hand
|
||||
elif content.startswith("blackjack split"):
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[2])
|
||||
except:
|
||||
handNumber = 0
|
||||
response, roundDone = blackjackSplit(str(message.channel),message.author.display_name,handNumber)
|
||||
|
||||
await message.channel.send(response)
|
||||
|
||||
try:
|
||||
if roundDone[0] == "T":
|
||||
with open("resources/games/games.json", "r") as f:
|
||||
gameID = json.load(f)["blackjack games"][str(message.channel)]["id"]
|
||||
logThis("Split calling blackjackLoop()",str(message.channel))
|
||||
await blackjackLoop(message.channel,int(roundDone[1:])+1,gameID)
|
||||
#except:
|
||||
# logThis("Something fucked up")
|
||||
# await message.channel.send("something fucked up")
|
||||
|
||||
# Returning current hi-lo value
|
||||
elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj":
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/hilo/"+str(message.channel)+".txt", "r") as f:
|
||||
data = f.read()
|
||||
else:
|
||||
data = "0"
|
||||
await message.channel.send(data)
|
||||
|
||||
# Shuffles the blackjack deck
|
||||
elif content.startswith("blackjack shuffle"):
|
||||
blackjackShuffle(blackjackDecks,str(message.channel))
|
||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
||||
await message.channel.send("Shuffling the deck...")
|
||||
|
||||
|
||||
# Tells you the amount of cards left
|
||||
elif content.startswith("blackjack cards"):
|
||||
cardsLeft = 0
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
||||
for _ in f:
|
||||
cardsLeft += 1
|
||||
|
||||
decksLeft = round(cardsLeft/52,1)
|
||||
await message.channel.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks")
|
||||
except:
|
||||
logThis("Something fucked up")
|
||||
|
||||
# Returning current hi-lo value
|
||||
elif content.startswith("blackjack hilo") and message.author.display_name == "Nikolaj":
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/hilo/"+str(message.channel)+".txt", "r") as f:
|
||||
data = f.read()
|
||||
else:
|
||||
logThis("Not a command (error code 1301)")
|
||||
await message.channel.send("I didn't quite understand that (error code 1301)")
|
||||
except:
|
||||
logThis("Something went wrong (error code 1300)")
|
||||
data = "0"
|
||||
await message.channel.send(data)
|
||||
|
||||
# Shuffles the blackjack deck
|
||||
elif content.startswith("blackjack shuffle"):
|
||||
blackjackShuffle(blackjackDecks,str(message.channel))
|
||||
logThis("Shuffling the blackjack deck...",str(message.channel))
|
||||
await message.channel.send("Shuffling the deck...")
|
||||
|
||||
|
||||
# Tells you the amount of cards left
|
||||
elif content.startswith("blackjack cards"):
|
||||
cardsLeft = 0
|
||||
if os.path.exists("resources/games/blackjackCards/"+str(message.channel)+".txt"):
|
||||
with open("resources/games/blackjackCards/"+str(message.channel)+".txt","r") as f:
|
||||
for _ in f:
|
||||
cardsLeft += 1
|
||||
|
||||
decksLeft = round(cardsLeft/52,1)
|
||||
await message.channel.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks")
|
||||
|
||||
else:
|
||||
logThis("Not a command (error code 1301)")
|
||||
await message.channel.send("I didn't quite understand that (error code 1301)")
|
||||
#except:
|
||||
# logThis("Something went wrong (error code 1300)")
|
||||
|
||||
# Runs a game of four in a row
|
||||
elif content.startswith("fourinarow"):
|
||||
@ -746,7 +561,7 @@ async def parseCommands(message,content):
|
||||
await fiar(message.channel,command,message.author.display_name)
|
||||
except:
|
||||
logThis("Something went wrong (error code 1400)")
|
||||
|
||||
|
||||
# Runs a game of Hex
|
||||
elif content.startswith("hex"):
|
||||
try:
|
||||
@ -754,7 +569,7 @@ async def parseCommands(message,content):
|
||||
await hex(message.channel,command,message.author.display_name)
|
||||
except:
|
||||
logThis("Something went wrong (error code 1500)")
|
||||
|
||||
|
||||
# Not a command
|
||||
else:
|
||||
logThis("That's not a command (error code 001)",str(message.channel))
|
||||
|
Reference in New Issue
Block a user