This commit is contained in:
jona605a
2020-08-04 10:24:44 +02:00
32 changed files with 853 additions and 24332 deletions

8
.gitignore vendored
View File

@ -150,12 +150,16 @@ static
.vscode/
token.txt
resources/swcharacters.json
resources/starWars/swcharacters.json
resources/games/games.json
resources/games/blackjackCards/
resources/games/hilo/
resources/destinyPoints.txt
resources/starWars/destinyPoints.txt
resources/games/blackjackTables/
resources/games/oldImages/
resources/games/4InARowBoards/
resources/lookup/monsters.json
resources/lookup/spells.json
resources/movies.txt
resources/names.txt
gwendolynTest.py

View File

@ -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))

View File

@ -1,19 +1,22 @@
# Gwendolyn
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/184c73090f274828adcf5a8066f773ed)](https://www.codacy.com?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=NikolajDanger/Gwendolyn&amp;utm_campaign=Badge_Grade)
Gwendolyn is a discord bot that I made. It does a bunch of stuff.
## Stuff it can do
* Roll dice!
* Look up D&D monsters and spells!
* Find random pictures!
* Find random movies!
* Generate names for taverns and people!
* Roll Star Wars RPG dice!
* Keep track of Star Wars RPG character sheets!
* Play trivia, connect 4 and blackjack
* Roll dice!
* Look up D&D monsters and spells!
* Find random pictures!
* Find random movies!
* Generate names for taverns and people!
* Roll Star Wars RPG dice!
* Keep track of Star Wars RPG character sheets!
* Play trivia, connect 4 and blackjack
And much more!!! (not really. That's pretty much all it can do. See help files in resources directory for list of commands)
## Setup
Running gwendolyn.py will help you set up. You will need a bot token on hand, which you should paste into your terminal when prompted.
You will need to populate monsters.json and spells.json with monsters and spells. The files are created in the resources folder when running the program.

View File

@ -1,11 +1,16 @@
"""A collection of all Gwendolyn functions."""
__all__ = ["helloFunc", "cap", "imageFunc", "logThis", "findWikiPage", "makeFiles", "emojiToNumber", "fiarReactionTest", "deleteGame", "stopServer", "checkBalance", "giveMoney", "addMoney", "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 .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple, emojiToNumber, fiarReactionTest, deleteGame, stopServer
from .swfuncs import *
from .games import checkBalance, giveMoney, addMoney, triviaCountPoints, triviaStart, triviaAnswer, blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit, parseFourInARow, fourInARowAI
from .lookup import *
from .lookup import spellFunc, monsterFunc
from .other import *
from .other import nameGen, tavernGen, movieFunc
from .games import *
from .roll import roll_dice
from .swfuncs import parseChar, parseRoll, parseDestiny, critRoll
from .roll import *

View File

@ -1,3 +1,7 @@
"""Functions for games Gwendolyn can play."""
__all__ = ["checkBalance", "giveMoney", "addMoney","triviaCountPoints", "triviaStart", "triviaAnswer", "blackjackShuffle", "blackjackStart", "blackjackPlayerDrawHand", "blackjackContinue", "blackjackFinish", "blackjackHit", "blackjackStand", "blackjackDouble", "blackjackSplit", "parseFourInARow", "fourInARowAI"]
from .money import checkBalance, giveMoney, addMoney
from .trivia import triviaCountPoints, triviaStart, triviaAnswer
from .blackjack import blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit

View File

@ -146,7 +146,7 @@ def blackjackContinue(channel):
data["blackjack games"][channel]["user hands"][user]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"]:
if data["blackjack games"][channel]["user hands"][user]["split"] > 0:
if data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["other hand"]["standing"] = True
@ -160,6 +160,34 @@ def blackjackContinue(channel):
data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"] > 1:
if data["blackjack games"][channel]["user hands"][user]["third hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] = True
if data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] == False:
allStanding = False
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["third hand"]["hand"]) >= 21 or data["blackjack games"][channel]["user hands"][user]["third hand"]["doubled"]:
data["blackjack games"][channel]["user hands"][user]["third hand"]["standing"] = True
else:
preAllStanding = False
data["blackjack games"][channel]["user hands"][user]["third hand"]["hit"] = False
if data["blackjack games"][channel]["user hands"][user]["split"] > 2:
if data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hit"] == False:
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] = True
if data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] == False:
allStanding = False
if calcHandValue(data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hand"]) >= 21 or data["blackjack games"][channel]["user hands"][user]["fourth hand"]["doubled"]:
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["standing"] = True
else:
preAllStanding = False
data["blackjack games"][channel]["user hands"][user]["fourth hand"]["hit"] = False
if allStanding:
data["blackjack games"][channel]["all standing"] = True
with open("resources/games/games.json", "w") as f:
@ -190,17 +218,19 @@ def blackjackHit(channel,user,handNumber = 0):
data = json.load(f)
if user in data["blackjack games"][channel]["user hands"]:
if data["blackjack games"][channel]["user hands"][user]["split"] == False:
if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
handNumber = 0
else:
if handNumber != 0:
if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 4:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else:
logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with."
@ -219,8 +249,12 @@ def blackjackHit(channel,user,handNumber = 0):
if handValue > 21:
hand["busted"] = True
if otherHand:
if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
elif handNumber == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
else:
data["blackjack games"][channel]["user hands"][user] = hand
@ -234,10 +268,18 @@ def blackjackHit(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False:
roundDone = False
if person["split"]:
if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else:
logThis(user+" is already standing")
@ -258,31 +300,31 @@ def blackjackDouble(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f:
data = json.load(f)
if data["blackjack games"][channel]["user hands"][user]["split"] == False:
if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
correctRound = 1
handNumber = 0
else:
if handNumber != 0:
if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else:
logThis(user+" tried to double without specifying which hand")
return "You have to specify the hand you're doubling down.",""
else:
logThis(user+" tried to double without specifying which hand")
return "You have to specify the hand you're doubling down.",""
correctRound = 2
if data["blackjack games"][channel]["round"] > 0:
if hand["hit"] == False:
if hand["standing"] == False:
if data["blackjack games"][channel]["round"] == correctRound:
if len(hand["hand"]) == 2:
bet = hand["bet"]
if money.checkBalance(user) >= bet:
money.addMoney(user,-1 * bet)
@ -300,8 +342,12 @@ def blackjackDouble(channel,user,handNumber = 0):
if handValue > 21:
hand["busted"] = True
if otherHand:
if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
elif handNumber == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = hand
else:
data["blackjack games"][channel]["user hands"][user] = hand
@ -314,10 +360,18 @@ def blackjackDouble(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False:
roundDone = False
if person["split"]:
if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth 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:
@ -342,17 +396,19 @@ def blackjackStand(channel,user,handNumber = 0):
data = json.load(f)
if user in data["blackjack games"][channel]["user hands"]:
if data["blackjack games"][channel]["user hands"][user]["split"] == False:
if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
handNumber = 0
else:
if handNumber != 0:
if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user]
otherHand = False
elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
otherHand = True
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
elif handNumber == 4:
hand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
else:
logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with."
@ -374,10 +430,18 @@ def blackjackStand(channel,user,handNumber = 0):
if person["hit"] == False and person["standing"] == False:
roundDone = False
if person["split"]:
if person["split"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth hand"]["standing"] == False:
roundDone = False
return response + str(roundDone)[0] + str(data["blackjack games"][channel]["round"])
else:
logThis(user+" is already standing")
@ -393,79 +457,136 @@ def blackjackStand(channel,user,handNumber = 0):
return "You have to enter the game before you can stand"
# When players try to split
def blackjackSplit(channel,user):
def blackjackSplit(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f:
data = json.load(f)
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]["standing"] == False:
if data["blackjack games"][channel]["round"] == 1:
firstCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][0]])
secondCard = calcHandValue([data["blackjack games"][channel]["user hands"][user]["hand"][1]])
if firstCard == secondCard:
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]["hit"] = True
data["blackjack games"][channel]["user hands"][user]["other hand"]["hit"] = True
data["blackjack games"][channel]["user hands"][user]["split"] = True
data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"] = data["blackjack games"][channel]["user hands"][user]["bet"]
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(data["blackjack games"][channel]["user hands"][user]["hand"].pop(1))
data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"].append(drawCard(channel))
data["blackjack games"][channel]["user hands"][user]["hand"].append(drawCard(channel))
handValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"])
otherHandValue = calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"])
if handValue > 21:
data["blackjack games"][channel]["user hands"][user]["busted"] = True
elif handValue == 21:
data["blackjack games"][channel]["user hands"][user]["blackjack"] = True
if otherHandValue > 21:
data["blackjack games"][channel]["user hands"][user]["other hand"]["busted"] = True
elif otherHandValue == 21:
data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] = True
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)
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:
logThis(user+" doesn't have enough GwendoBucks")
return "You don't have enough GwendoBucks",""
else:
logThis(user+" tried to split 2 different cards")
return "Your cards need to have the same value to split",""
else:
logThis(user+" tried to split on round "+data["blackjack games"][channel]["round"])
return "You can only split on the first round",""
else:
logThis(user+" is already standing")
return "You can't split when you're standing",""
else:
logThis(user+" has already hit this round")
return "You've already hit this round",""
if data["blackjack games"][channel]["user hands"][user]["split"] == 0:
hand = data["blackjack games"][channel]["user hands"][user]
newHand = data["blackjack games"][channel]["user hands"][user]["other hand"]
handNumber = 0
otherHand = 2
else:
logThis(user+" tried to split on the 0th round")
return "You can't split before you see your cards",""
if handNumber != 0:
if handNumber == 1:
hand = data["blackjack games"][channel]["user hands"][user]
elif handNumber == 2:
hand = data["blackjack games"][channel]["user hands"][user]["other hand"]
elif handNumber == 3:
hand = data["blackjack games"][channel]["user hands"][user]["third hand"]
else:
logThis(user+" tried to hit without specifying which hand")
return "You have to specify the hand you're hitting with."
if data["blackjack games"][channel]["user hands"][user]["split"] == 1:
newHand = data["blackjack games"][channel]["user hands"][user]["third hand"]
otherHand = 3
else:
newHand = data["blackjack games"][channel]["user hands"][user]["fourth hand"]
otherHand = 4
else:
logThis(user+" tried to split without specifying which hand")
return "You have to specify the hand you're splitting.",""
if data["blackjack games"][channel]["user hands"][user]["split"] < 3:
if data["blackjack games"][channel]["round"] != 0:
if hand["hit"] == False:
if hand["standing"] == False:
if len(hand["hand"]) == 2:
firstCard = calcHandValue([hand["hand"][0]])
secondCard = calcHandValue([hand["hand"][1]])
if firstCard == secondCard:
bet = hand["bet"]
if money.checkBalance(user) >= bet:
money.addMoney(user,-1 * bet)
with open("resources/games/games.json", "r") as f:
data = json.load(f)
hand["hit"] = True
newHand["hit"] = True
newHand = {
"hand":[],"bet":0,"standing":False,"busted":False,
"blackjack":False,"hit":True,"doubled":False}
newHand["bet"] = hand["bet"]
newHand["hand"].append(hand["hand"].pop(1))
newHand["hand"].append(drawCard(channel))
hand["hand"].append(drawCard(channel))
handValue = calcHandValue(hand["hand"])
otherHandValue = calcHandValue(newHand["hand"])
if handValue > 21:
hand["busted"] = True
elif handValue == 21:
hand["blackjack"] = True
if otherHandValue > 21:
newHand["busted"] = True
elif otherHandValue == 21:
newHand["blackjack"] = True
if handNumber == 2:
data["blackjack games"][channel]["user hands"][user]["other hand"] = hand
elif handNumber == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = hand
else:
data["blackjack games"][channel]["user hands"][user] = hand
if otherHand == 3:
data["blackjack games"][channel]["user hands"][user]["third hand"] = newHand
elif otherHand == 4:
data["blackjack games"][channel]["user hands"][user]["fourth hand"] = newHand
else:
data["blackjack games"][channel]["user hands"][user]["other hand"] = newHand
data["blackjack games"][channel]["user hands"][user]["split"] += 1
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)
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"] > 0:
if person["other hand"]["hit"] == False and person["other hand"]["standing"] == False:
roundDone = False
if person["split"] > 1:
if person["third hand"]["hit"] == False and person["third hand"]["standing"] == False:
roundDone = False
if person["split"] > 2:
if person["fourth hand"]["hit"] == False and person["fourth 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:
logThis(user+" doesn't have enough GwendoBucks")
return "You don't have enough GwendoBucks",""
else:
logThis(user+" tried to split 2 different cards")
return "Your cards need to have the same value to split",""
else:
logThis(user+" tried to split later than they could")
return "You can only split on the first round",""
else:
logThis(user+" is already standing")
return "You can't split when you're standing",""
else:
logThis(user+" has already hit this round")
return "You've already hit this round",""
else:
logThis(user+" tried to split on the 0th round")
return "You can't split before you see your cards",""
else:
logThis(user+" tried to split more than three times")
return "You can only split 3 times",""
# Player enters the game and draws a hand
def blackjackPlayerDrawHand(channel,user,bet):
@ -491,15 +612,11 @@ def blackjackPlayerDrawHand(channel,user,bet):
if handValue == 21:
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
"bet":bet,"standing":False,"busted":False,"blackjack":True,"hit":True,
"doubled":False,"split":False,"other hand":{
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False}}
"doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
else:
data["blackjack games"][channel]["user hands"][user] = {"hand":playerHand,
"bet":bet,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False,"split":False,"other hand":{
"hand":[],"bet":0,"standing":False,"busted":False,"blackjack":False,"hit":True,
"doubled":False}}
"doubled":False,"split":0,"other hand":{},"third hand":{},"fourth hand":{}}
with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4)
@ -560,69 +677,32 @@ def blackjackFinish(channel):
data = json.load(f)
dealerValue = calcHandValue(data["blackjack games"][channel]["dealer hand"])
reason = ""
dealerBlackjack = data["blackjack games"][channel]["dealer blackjack"]
dealerBusted = data["blackjack games"][channel]["dealer busted"]
for user in data["blackjack games"][channel]["user hands"]:
winnings = -1 * data["blackjack games"][channel]["user hands"][user]["bet"]
if data["blackjack games"][channel]["user hands"][user]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
reason = "(blackjack)"
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["bet"])
elif data["blackjack games"][channel]["dealer blackjack"]:
reason += "(dealer blackjack)"
elif data["blackjack games"][channel]["user hands"][user]["busted"]:
reason = "(busted)"
else:
if data["blackjack games"][channel]["dealer busted"]:
reason = "(dealer busted)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) > dealerValue:
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
reason = "(highest value)"
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) == dealerValue:
reason = "(pushed)"
winnings += data["blackjack games"][channel]["user hands"][user]["bet"]
else:
reason = "(highest value)"
try:
for user in data["blackjack games"][channel]["user hands"]:
if data["blackjack games"][channel]["user hands"][user]["split"]:
winnings -= data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
if data["blackjack games"][channel]["user hands"][user]["other hand"]["blackjack"] and data["blackjack games"][channel]["dealer blackjack"] == False:
reason += "(blackjack)"
winnings += math.floor(2.5 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"])
elif data["blackjack games"][channel]["dealer blackjack"]:
reason += "(dealer blackjack)"
elif data["blackjack games"][channel]["user hands"][user]["other hand"]["busted"]:
reason += "(busted)"
else:
if data["blackjack games"][channel]["dealer busted"]:
reason += "(dealer busted)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"]) > dealerValue:
reason += "(highest value)"
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["other hand"]["hand"]) == dealerValue:
reason += "(pushed)"
winnings += data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
try:
winnings, netWinnings, reason = calcWinnings(data["blackjack games"][channel]["user hands"][user],dealerValue,True,dealerBlackjack,dealerBusted)
except:
logThis("Error calculating winnings for "+str(user)+" (error code 1312)")
if winnings < 0:
if winnings == -1:
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBuck "+reason+"\n"
else:
reason += "(highest value)"
if winnings < 0:
if winnings == -1:
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBuck "+reason+"\n"
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBucks "+reason+"\n"
else:
finalWinnings += user+" lost "+str(-1 * winnings)+" GwendoBucks "+reason+"\n"
else:
if winnings == 1:
finalWinnings += user+" won "+str(winnings)+" GwendoBuck "+reason+"\n"
else:
finalWinnings += user+" won "+str(winnings)+" GwendoBucks "+reason+"\n"
netWinnings = winnings + data["blackjack games"][channel]["user hands"][user]["bet"] + data["blackjack games"][channel]["user hands"][user]["other hand"]["bet"]
if winnings == 1:
finalWinnings += user+" won "+str(winnings)+" GwendoBuck "+reason+"\n"
else:
finalWinnings += user+" won "+str(winnings)+" GwendoBucks "+reason+"\n"
money.addMoney(user,netWinnings)
money.addMoney(user,netWinnings)
except:
logThis("Error calculating winnings (error code 1311)")
with open("resources/games/games.json", "r") as f:
data = json.load(f)
@ -633,3 +713,56 @@ def blackjackFinish(channel):
json.dump(data,f,indent=4)
return finalWinnings
def calcWinnings(hand, dealerValue, topLevel, dealerBlackjack, dealerBusted):
logThis("Calculating winnings")
reason = ""
bet = hand["bet"]
winnings = -1 * bet
netWinnings = 0
handValue = calcHandValue(hand["hand"])
if hand["blackjack"] and dealerBlackjack == False:
reason += "(blackjack)"
winnings += math.floor(2.5 * bet)
netWinnings += math.floor(2.5 * bet)
elif dealerBlackjack:
reason += "(dealer blackjack)"
elif hand["busted"]:
reason += "(busted)"
else:
if dealerBusted:
reason = "(dealer busted)"
winnings += 2 * bet
netWinnings += 2 * bet
elif handValue > dealerValue:
winnings += 2 * bet
netWinnings += 2 * bet
reason = "(highest value)"
elif handValue == dealerValue:
reason = "(pushed)"
winnings += bet
netWinnings += bet
else:
reason = "(highest value)"
if topLevel:
if hand["split"] >= 1:
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["other hand"],dealerValue,False,dealerBlackjack,dealerBusted)
winnings += winningsTemp
netWinnings += netWinningsTemp
reason += reasonTemp
if hand["split"] >= 2:
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["third hand"],dealerValue,False,dealerBlackjack,dealerBusted)
winnings += winningsTemp
netWinnings += netWinningsTemp
reason += reasonTemp
if hand["split"] >= 3:
winningsTemp, netWinningsTemp, reasonTemp = calcWinnings(hand["fourth hand"],dealerValue,False,dealerBlackjack,dealerBusted)
winnings += winningsTemp
netWinnings += netWinningsTemp
reason += reasonTemp
return winnings, netWinnings, reason

View File

@ -1,4 +1,4 @@
import json, random
import json
from PIL import Image, ImageDraw, ImageFont
@ -33,7 +33,21 @@ def drawImage(channel):
key, value = list(hands.items())[x]
userHand = drawHand(value["hand"],False,value["busted"],value["blackjack"])
if value["split"]:
if value["split"] == 3:
table.paste(userHand,(32-borderSmol+(384*placement[x]),280-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),420-borderSmol),userOtherHand)
userThirdHand = drawHand(value["third hand"]["hand"],False,value["third hand"]["busted"],value["third hand"]["blackjack"])
table.paste(userThirdHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userOtherHand)
userFourthHand = drawHand(value["fourth hand"]["hand"],False,value["fourth hand"]["busted"],value["fourth hand"]["blackjack"])
table.paste(userFourthHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)
elif value["split"] == 2:
table.paste(userHand,(32-borderSmol+(384*placement[x]),420-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userOtherHand)
userThirdHand = drawHand(value["third hand"]["hand"],False,value["third hand"]["busted"],value["third hand"]["blackjack"])
table.paste(userThirdHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)
elif value["split"] == 1:
table.paste(userHand,(32-borderSmol+(384*placement[x]),560-borderSmol),userHand)
userOtherHand = drawHand(value["other hand"]["hand"],False,value["other hand"]["busted"],value["other hand"]["blackjack"])
table.paste(userOtherHand,(32-borderSmol+(384*placement[x]),700-borderSmol),userOtherHand)

View File

@ -8,7 +8,7 @@ def checkBalance(user):
logThis("checking "+user+"'s account balance")
with open("resources/games/games.json", "r") as f:
data = json.load(f)
if user in data["users"]:
return data["users"][user]
else: return 0

View File

@ -1 +1,5 @@
"""Gwendolyn functions for looking things up."""
__all__ = ["spellFunc", "monsterFunc"]
from .lookupFuncs import spellFunc, monsterFunc

View File

@ -1,5 +1,5 @@
import math
import discord
#import discord
import json
from funcs import cap, logThis
@ -24,9 +24,9 @@ def monsterFunc(command):
return("I don't know that monster... (error code 601)","","","","","")
else:
# Opens "mensters.json"
data = json.load(open('resources/monsters.json', encoding = "utf8"))
data = json.load(open('resources/lookup/monsters.json', encoding = "utf8"))
for monster in data:
if str(command) == monster["name"]:
if "name" in monster and str(command) == monster["name"]:
logThis("Found it!")
# Looks at the information about the monster and returns that information
@ -125,7 +125,7 @@ def spellFunc(command):
logThis("Looking up "+command)
# Opens "spells.json"
data = json.load(open('resources/spells.json', encoding = "utf8"))
data = json.load(open('resources/lookup/spells.json', encoding = "utf8"))
if str(command) in data:
logThis("Returning spell information")
spell_output = ("***"+str(command)+"***\n*"+str(data[str(command)]["level"])+" level "+str(data[str(command)]["school"])+"\nCasting Time: "+str(data[str(command)]["casting_time"])+"\nRange: "+str(data[str(command)]["range"])+"\nComponents: "+str(data[str(command)]["components"])+"\nDuration: "+str(data[str(command)]["duration"])+"*\n \n"+str(data[str(command)]["description"]))

View File

@ -1,16 +1,12 @@
import lxml.etree # Used by imageFunc
import re # Used by roll_dice
import datetime # Used by helloFunc
import json # Used by spellFunc
#import random # Used by imageFunc
import random # Used by imageFunc
import urllib # Used by imageFunc
import imdb # Used by movieFunc
import time # Used for logging
import logging # Used for... you know... logging
import wikia # Used by findWikiPage
import os
from .roll import dice
import os # Used by makeFiles
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
@ -54,29 +50,32 @@ def helloFunc(author):
# Finds a random picture online
def imageFunc():
# Picks a type of camera, which decides the naming scheme
cams = ("one","two","three","four")
cam = random.choice(cams)
logThis("Chose cam type "+cam)
if cam == "one":
a = str(random.randint(0 ,9))
b = str(random.randint(0,9))
c = str(random.randint(0,9))
d = str(random.randint(0,9))
search = ("img_"+a+b+c+d)
elif cam == "two":
a = str(random.randint(2012,2016))
b = str(random.randint(1,12)).zfill(2)
c = str(random.randint(1,29)).zfill(2)
search = ("IMG_"+a+b+c)
elif cam == "three":
a = str(random.randint(1,500)).zfill(4)
search = ("IMAG_"+a)
elif cam == "four":
a = str(random.randint(0,9))
b = str(random.randint(0,9))
c = str(random.randint(0,9))
d = str(random.randint(0,9))
search = ("DSC_"+a+b+c+d)
try:
cams = ("one","two","three","four")
cam = random.choice(cams)
logThis("Chose cam type "+cam)
if cam == "one":
a = str(random.randint(0 ,9))
b = str(random.randint(0,9))
c = str(random.randint(0,9))
d = str(random.randint(0,9))
search = ("img_"+a+b+c+d)
elif cam == "two":
a = str(random.randint(2012,2016))
b = str(random.randint(1,12)).zfill(2)
c = str(random.randint(1,29)).zfill(2)
search = ("IMG_"+a+b+c)
elif cam == "three":
a = str(random.randint(1,500)).zfill(4)
search = ("IMAG_"+a)
elif cam == "four":
a = str(random.randint(0,9))
b = str(random.randint(0,9))
c = str(random.randint(0,9))
d = str(random.randint(0,9))
search = ("DSC_"+a+b+c+d)
except:
logThis("error picking camera type (error code 702)")
logThis("Searching for "+search)
@ -138,11 +137,11 @@ def findWikiPage(search : str):
def makeFiles():
# Creates swcharacters.json if it doesn't exist
try:
f = open("resources/swcharacters.json","r")
f = open("resources/starWars/swcharacters.json","r")
except:
logThis("swcharacters.json didn't exist. Making it now.")
emptyDict = {}
with open("resources/swcharacters.json","w") as f:
with open("resources/starWars/swcharacters.json","w") as f:
json.dump(emptyDict,f,indent = 4)
finally:
f.close()
@ -158,16 +157,59 @@ def makeFiles():
finally:
f.close()
# Creates monsters.json if it doesn't exist
try:
f = open("resources/lookup/monsters.json","r")
except:
logThis("monsters.json didn't exist. Making it now.")
with open("resources/lookup/lookupExamples.json") as f:
data = json.load(f)["monster"]
with open("resources/lookup/monsters.json","w") as f:
json.dump(data,f,indent = 4)
finally:
f.close()
# Creates spells.json if it doesn't exist
try:
f = open("resources/lookup/spells.json","r")
except:
logThis("spells.json didn't exist. Making it now.")
with open("resources/lookup/lookupExamples.json") as f:
data = json.load(f)["spell"]
with open("resources/lookup/spells.json","w") as f:
json.dump(data,f,indent = 4)
finally:
f.close()
# Creates destinyPoints.txt if it doesn't exist
try:
f = open("resources/destinyPoints.txt","r")
f = open("resources/starWars/destinyPoints.txt","r")
except:
logThis("destinyPoints.txt didn't exist. Making it now.")
with open("resources/destinyPoints.txt","w") as f:
with open("resources/starWars/destinyPoints.txt","w") as f:
f.write("")
finally:
f.close()
# Creates movies.txt if it doesn't exist
try:
f = open("resources/movies.txt","r")
except:
logThis("movies.txt didn't exist. Making it now.")
with open("resources/movies.txt","w") as f:
f.write("The Room")
finally:
f.close()
# Creates names.txt if it doesn't exist
try:
f = open("resources/names.txt","r")
except:
logThis("names.txt didn't exist. Making it now.")
with open("resources/names.txt","w") as f:
f.write("Gandalf")
finally:
f.close()
# Creates token.txt if it doesn't exist
try:

View File

@ -1,2 +1,6 @@
"""Misc. functions for Gwendolyn."""
__all__ = ["nameGen", "tavernGen", "movieFunc"]
from .generators import nameGen, tavernGen
from .movie import movieFunc

View File

@ -1,4 +1,4 @@
import numpy as np
#import numpy as np
import random
from funcs import logThis

View File

@ -17,7 +17,7 @@ def movieFunc():
movs.close()
except:
logThis("Problem picking the movie (error code 801)")
return("error","801","","")
return("error","804","","")
try:
logThis("Searching for "+mov)
@ -42,5 +42,5 @@ def movieFunc():
logThis("Successfully ran !movie")
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
except:
logThis("Something bad happened... (error code 800)")
return("error","800","","")
logThis("Something bad happened... (error code 801)")
return("error","801","","")

View File

@ -1 +1,5 @@
"""I stole this."""
__all__ = ["roll_dice"]
from .dice import roll_dice

View File

@ -1,3 +1,7 @@
"""Functions related to the Star Wars TTRPG."""
__all__ = ["parseChar", "parseRoll", "critRoll", "parseDestiny"]
from .swchar import parseChar
from .swroll import parseRoll, critRoll
from .swdestiny import parseDestiny

View File

@ -5,7 +5,7 @@ from funcs import logThis
def getName(user : str):
logThis("Getting name for "+user+"'s character")
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
if user in data:
@ -238,7 +238,7 @@ def characterSheet(character : dict):
return name, text1+text2+"\n\n"+text3+divider+text4+"\n"+divider+text5+text6+text7+text8
def charData(user : str,cmd : str):
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
key = string.capwords(cmd.split(" ")[0])
@ -285,7 +285,7 @@ def charData(user : str,cmd : str):
cmd[1] = cmd[1][1:]
logThis("Adding "+cmd[0]+" to "+key)
data[user][key][cmd[0]] = cmd[1]
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return cmd[0]+" added to "+key+" for " + data[user]["Name"]
@ -299,18 +299,18 @@ def charData(user : str,cmd : str):
except:
logThis("Fucked that up (error code 949)")
return "Wrong data type (error code 949)"
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return cmd[0]+" added to "+key+" for " + data[user]["Name"]
elif key == "Weapons":
with open("resources/swtemplates.json", "r") as f:
with open("resources/starWars/swtemplates.json", "r") as f:
templates = json.load(f)
newWeapon = templates["Weapon"]
logThis("Adding "+cmd+" to "+key)
data[user][key][cmd] = newWeapon
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return cmd+" added to weapons for " + data[user]["Name"]
@ -332,7 +332,7 @@ def charData(user : str,cmd : str):
logThis("Trying to remove "+cmd+" from "+key)
if cmd in data[user][key]:
del data[user][key][cmd]
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
logThis("I did that")
return cmd+" removed from "+key+" from "+data[user]["Name"]
@ -356,7 +356,7 @@ def charData(user : str,cmd : str):
if type(lookUpResult) is dict:
data[user][key] = lookUpResult
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key
else:
@ -383,7 +383,7 @@ def charData(user : str,cmd : str):
logThis("Adding "+cmd+" to "+key)
beforeData = data[user][key]
data[user][key] = beforeData+ int(cmd)
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except:
@ -393,7 +393,7 @@ def charData(user : str,cmd : str):
try:
logThis("Adding "+cmd+" to "+key)
data[user][key].append(cmd)
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except:
@ -417,7 +417,7 @@ def charData(user : str,cmd : str):
logThis("Subtracting "+cmd+" from "+key)
beforeData = data[user][key]
data[user][key] = beforeData - int(cmd)
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Subtracted " + cmd + " from " + data[user]["Name"] + "'s " + key
except:
@ -432,7 +432,7 @@ def charData(user : str,cmd : str):
except:
logThis("They can only remove stuff that's actually in the list")
return "Not in list (error code 944b)"
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Removed " + cmd + " from " + data[user]["Name"] + "'s " + key
except:
@ -455,7 +455,7 @@ def charData(user : str,cmd : str):
logThis("I don't wanna tho (error code 945a)")
return "Can't do that (error code 945a)"
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
else:
@ -487,7 +487,7 @@ def parseChar(user : str, cmd : str):
cmd = replaceSpaces(cmd)
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
if cmd == " ":
@ -504,31 +504,31 @@ def parseChar(user : str, cmd : str):
return text1, replaceWithSpaces(text2)
else:
logThis("Makin' a character for "+user)
with open("resources/swtemplates.json", "r") as f:
with open("resources/starWars/swtemplates.json", "r") as f:
templates = json.load(f)
newChar = templates["Character"]
data[user] = newChar
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "", "Character for " + user + " created"
else:
if cmd == "Purge":
logThis("Deleting "+user+"'s character")
del data[user]
with open("resources/swcharacters.json", "w") as f:
with open("resources/starWars/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "", "Character for " + user + " deleted"
return "", replaceWithSpaces(str(charData(user,cmd)))
def lightsaberChar(user : str):
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
if user in data:
return data[user]["Lightsaber-characteristic"]
def userHasChar(user : str):
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
return user in data

View File

@ -7,13 +7,13 @@ def destinyNew(num : int):
roll, diceResults = swroll.roll(0,0,0,0,0,0,num)
roll = "".join(sorted(roll))
with open("resources/destinyPoints.txt","wt") as f:
with open("resources/starWars/destinyPoints.txt","wt") as f:
f.write(roll)
return "Rolled for Destiny Points and got:\n"+swroll.diceResultToEmoji(diceResults)+"\n"+swroll.resultToEmoji(roll)
def destinyUse(user : str):
with open("resources/destinyPoints.txt","rt") as f:
with open("resources/starWars/destinyPoints.txt","rt") as f:
points = f.read()
if user == "Nikolaj":
@ -21,7 +21,7 @@ def destinyUse(user : str):
if 'B' in points:
points = points.replace("B","L",1)
points = "".join(sorted(points))
with open("resources/destinyPoints.txt","wt") as f:
with open("resources/starWars/destinyPoints.txt","wt") as f:
f.write(points)
logThis("Did it")
return "Used a dark side destiny point. Destiny pool is now:\n"+swroll.resultToEmoji(points)
@ -33,7 +33,7 @@ def destinyUse(user : str):
if 'L' in points:
points = points.replace("L","B",1)
points = "".join(sorted(points))
with open("resources/destinyPoints.txt","wt") as f:
with open("resources/starWars/destinyPoints.txt","wt") as f:
f.write(points)
logThis("Did it")
return "Used a light side destiny point. Destiny pool is now:\n"+swroll.resultToEmoji(points)
@ -51,7 +51,7 @@ def parseDestiny(user : str, cmd : str):
if cmd == "":
logThis("Retrieving destiny pool info")
with open("resources/destinyPoints.txt","rt") as f:
with open("resources/starWars/destinyPoints.txt","rt") as f:
return swroll.resultToEmoji(f.read())
else:
commands = cmd.upper().split(" ")

View File

@ -2,12 +2,11 @@ import random
import re
import string
import json
import os
from . import swchar
from funcs import logThis
with open("resources/swskills.json", "r") as f:
with open("resources/starWars/swskills.json", "r") as f:
skillData = json.load(f)
# Rolls the specified dice
@ -224,7 +223,7 @@ def diceToEmoji(dice : list):
# Rolls for obligation
def obligationRoll():
logThis("Rolling for obligation")
with open("resources/swcharacters.json", "r") as f:
with open("resources/starWars/swcharacters.json", "r") as f:
data = json.load(f)
table = []

138
gameLoops.py Normal file
View File

@ -0,0 +1,138 @@
import asyncio
import discord
import json
from funcs import logThis, addMoney, deleteGame, parseFourInARow, fourInARowAI, blackjackContinue, blackjackFinish
# 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
# 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))
# Loop of blackjack 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))
try:
if allStanding:
await asyncio.sleep(5)
else:
await asyncio.sleep(120)
except:
logThis("Loop "+str(gameRound)+" interrupted (error code 1321)")
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:
try:
new_message = blackjackFinish(str(channel))
except:
logThis("Something fucked up (error code 1310)")
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))

View File

@ -32,12 +32,15 @@
7 - Image
700 - Unspecified error
701 - Can't connect to Bing
702 - Error picking camera type/image name
8 - Movie
800 - Unspecified error
801 - Can't pick movie
801 - Error in function
802 - Can't find movie on imdb
803 - Can't extract data
804 - Can't pick movie
805 - Embed error
9 - Star Wars
910 - Unspecified swroll error
@ -84,10 +87,15 @@
1223b - Not enough money
13 - Blackjack
1300 - Unspecified
1300 - Unspecified error
1310 - Unspecified finishing error
1311 - Error calculating winnings
1312 - Error in calcWinnings function
1320 - Unspecified loop error
1321 - Loop interrupted while waiting
14 - Four in a row
1400 - Unspecified
1400 - Unspecified error
1401 - Error deleting old image
1410 - Unspecified parsing error
1420 - Unspecified AI error

View File

@ -1,7 +0,0 @@
{
"trivia questions": {},
"users": {
"nikolaj": 1,
"jonathanh\u00f8jlev": 6
}
}

View File

@ -1,208 +0,0 @@
2s
3s
0s
7s
jh
7h
8c
kh
0d
js
ks
qh
2c
4c
kc
3h
kc
3c
2h
5d
9h
2d
3s
ks
6s
9d
2s
8s
qd
8d
6s
9s
js
5c
9s
ac
6s
6h
6h
0c
2d
ad
qh
qc
qh
7c
0d
8d
2h
as
jc
3d
9c
kd
4c
4d
ah
kd
8c
8h
5d
qc
9s
0c
qh
jh
0s
8d
6c
8h
5c
3c
0h
4h
8c
6d
5c
4d
2c
7s
2s
ks
5s
ah
jd
ah
8h
0h
4h
3d
7c
4d
ad
3h
9h
3h
6c
5s
6d
jd
7c
ks
7d
0s
jd
8s
ah
0s
as
7d
2d
4s
qs
3s
9h
9c
4c
4h
3c
5c
as
8s
9d
7c
5d
6d
3d
kc
jc
6s
4s
5h
9d
2h
qd
qc
qs
6d
jh
ac
as
5h
6h
jc
ad
7h
4c
9d
5h
kh
0h
7d
7h
9c
8c
qc
4s
qs
0c
jh
ac
9s
4h
3h
ad
kc
kh
qs
5d
jc
qd
8s
js
ac
js
jd
kd
qd
2s
4d
2h
5h
7d
6c
0c
6h
4s
0d
8d
7h
2c
2d
9c
7s
6c
5s
3d
3s
9h
8h
3c
0d
0h
7s
2c
kd
5s
kh

View File

@ -1 +0,0 @@
0

View File

@ -0,0 +1,56 @@
{
"monster" : [
{
"name": "Bandit",
"size": "Medium",
"type": "humanoid",
"subtype": "any race",
"alignment": "any non-lawful alignment",
"armor_class": 12,
"hit_points": 11,
"hit_dice": "2d8",
"speed": "30 ft.",
"strength": 11,
"dexterity": 12,
"constitution": 12,
"intelligence": 10,
"wisdom": 10,
"charisma": 10,
"damage_vulnerabilities": "",
"damage_resistances": "",
"damage_immunities": "",
"condition_immunities": "",
"senses": "passive Perception 10",
"languages": "any one language (usually Common)",
"challenge_rating": "1/8",
"actions": [
{
"name": "Scimitar",
"desc": "Melee Weapon Attack: +3 to hit, reach 5 ft., one target. Hit: 4 (1d6 + 1) slashing damage.",
"attack_bonus": 3,
"damage_dice": "1d6",
"damage_bonus": 1
},
{
"name": "Light Crossbow",
"desc": "Ranged Weapon Attack: +3 to hit, range 80 ft./320 ft., one target. Hit: 5 (1d8 + 1) piercing damage.",
"attack_bonus": 3,
"damage_dice": "1d8",
"damage_bonus": 1
}
]
}
],
"spell": {
"Fireball" : {
"casting_time" : "1 action",
"components" : "V, S, M (a tiny ball of bat guano and sulfur)",
"description" : "A bright streak flashes from your pointing finger to a point you choose within range and then blossoms with a low roar into an explosion of flame. Each creature in a 20-foot-radius sphere centered on that point must make a Dexterity saving throw. A target takes 8d6 fire damage on a failed save, or half as much damage on a successful one. The fire spreads around corners. It ignites flammable objects in the area that arent being worn or carried. At Higher Levels. When you cast this spell using a spell slot of 4th level or higher, the damage increases by 1d6 for each slot level above 3rd.",
"duration" : "Instantaneous",
"level" : "3rd",
"range" : "150 feet",
"school" : "Evocation",
"ritual" : false
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,307 +0,0 @@
Eddard Ned Stark
Robert Baratheon
Jaime Lannister
Catelyn Stark
Cersei Lannister
Daenerys Targaryen
Jorah Mormont
Viserys Targaryen
Jon Snow
Sansa Stark
Arya Stark
Robb Stark
Theon Greyjoy
Bran Stark
Joffrey Baratheon
Sandor The Hound Clegane
Tyrion Lannister
Khal Drogo
Petyr Littlefinger Baelish
Davos Seaworth
Samwell Tarly
Stannis Baratheon
Melisandre
Jeor Mormont
Bronn
Varys
Shae
Margaery Tyrell
Tywin Lannister
Talisa Maegyr
Ygritte
Gendry
Tormund Giantsbane
Brienne of Tarth
Ramsay Bolton
Gilly
Daario Naharis
Missandei
Ellaria Sand
Tommen Baratheon
Jaqen H'ghar
Roose Bolton
The High Sparrow
Grand Maester Pycelle
Meryn Trant
Hodor
Grenn
Osha
Rickon Stark
Ros
Gregor Clegane
Janos Slynt
Lancel Lannister
Myrcella Baratheon
Rodrik Cassel
Maester Luwin
Irri
Doreah
Kevan Lannister
Barristan Selmy
Rast
Maester Aemon
Pypar
Alliser Thorne
Othell Yarwyck
Loras Tyrell
Hot Pie
Beric Dondarrion
Podrick Payne
Eddison Tollett
Yara Greyjoy
Selyse Florent
Little Sam
Grey Worm
Qyburn
Olenna Tyrell
Shireen Baratheon
Meera Reed
Jojen Reed
Thoros of Myr
Yohn Royce
Olly
Mace Tyrell
The Waif
Bowen Marsh
Aragorn
Arwen
Bilbo
Boromir
Celeborn
Denethor
Elrond
Eomer
Eowyn
Faramir
Frodo
Galadriel
Gandalf
Gimli
Gollum
Legolas
Merry
Mouth of Sauron
Old Man Willow
Pippin
Radagast
Sam
Saruman
Sauron
Shelob
Theoden
Tom Bombadil
Treebeard
Witch king
Wormtongue
Adon
Methrammar Aerasume
Sernius Alathar
Alaundo
Alias
Alicia Kendrick
Arganth Snarrl
Khelben Arunsun
Jorus Azuremantle
Berg'inyon Baenre
Dantrag Baenre
Gromph Baenre
Liriel Baenre
Quenthel Baenre
Triel Baenre
Yvonnel Baenre
Balduron
Bruenor Battlehammer
Akabar Bel Akash
Belhifet
Aballister Bonaduce
Erevis Cale
Captain Deudermont
Catti-brie
Clacker
Companions of the Hall
Elaith Craulnober
Cyric
Danica Maupoissant
Montolio Debrouchee
Briza Do'Urden
Dinin Do'Urden
Malice Do'Urden
Maya Do'Urden
Nalfein Do'Urden
Shi'nayne Do'Urden
Vartha Do'Urden
Vierna Do'Urden
Drizzt Do'Urden
Dove Falconhand
Dragonbait
Gareth Dragonsbane
Elk Tribe
Ellifain
Elminster
Artemis Entreri
Errtu
Galaeron Nihmedu
Volothamp Geddarm
Halisstra Melarn
Halueth Never
Harkle Harpell
Taern Hornblade
Imoen
Ingeloakastimizilian
Innovindil
Ivan and Pikel Bouldershoulder
Jander Sunstar
Jarlaxle
Kelemvor Lyonsbane
Kierkan Rufo
Manshoon
Obould Many-Arrows
Minder the Golem
Minsc
Pharaun Mizzrym
Arilyn Moonblade
Narnra Shalace
Nasher Alagondar
Taegan Nightwind
Nimor Imphraezl
Thibbledorf Pwent
Regis Rumblebelly
Rizzen Do'Urden
Sammaster
Seven Sisters
Shandril Shessair
Alustriel Silverhand
The Simbul
Storm Silverhand
Sylune
Szass Tam
Tarathiel
Araevin Teshurr
Danilo Thann
Urlgen Threefist
Valas Hune
Vangerdahast
Wulfgar
Finder Wyvernspur
Yharaskrik
Zaknafein Do'Urden
Johnny Depp
Arnold Schwarzenegger
Jim Carrey
Emma Watson
Daniel Radcliffe
Leonardo DiCaprio
Tom Cruise
Brad Pitt
Charles Chaplin
Morgan Freeman
Tom Hanks
Hugh Jackman
Matt Damon
Sylvester Stallone
Will Smith
Clint Eastwood
Cameron Diaz
George Clooney
Steven Spielberg
Harrison Ford
Robert De Niro
Al Pacino
Robert Downey Jr.
Russell Crowe
Liam Neeson
Kate Winslet
Mark Wahlberg
Natalie Portman
Pierce Brosnan
Sean Connery
Orlando Bloom
Dwayne Johnson
Jackie Chan
Angelina Jolie
Adam Sandler
Scarlett Johansson
Heath Ledger
Anne Hathaway
Jessica Alba
Edward Norton
Keira Knightley
Bradley Cooper
Will Ferrell
Julia Roberts
Nicolas Cage
Daniel Craig
Keanu Reeves
Ian McKellen
Halle Berry
Bruce Willis
Samuel L. Jackson
Ben Stiller
Tommy Lee Jones
Antonio Banderas
Denzel Washington
Steve Carell
Shia LaBeouf
Megan Fox
James Franco
Mel Gibson
Vin Diesel
Tim Allen
Robin Williams
Kevin Spacey
Jason Biggs
Seann William Scott
Jean-Claude Van Damme
Zach Galifianakis
Owen Wilson
Christian Bale
Peter Jackson
Sandra Bullock
Bruce Lee
Drew Barrymore
Macaulay Culkin
Jack Nicholson
Bill Murray
Sigourney Weaver
Jake Gyllenhaal
Kamal Haasan
Jason Statham
Jet Li
Kate Beckinsale
Rowan Atkinson
Marlon Brando
John Travolta
Channing Tatum
Ben Affleck
Shah Rukh Khan
Jennifer Aniston
Emma Stone
Chris Hemsworth
James McAvoy
James Cameron
Amitabh Bachchan
Brendan Fraser
Rachel McAdams
Tom Hiddleston
Aamir Khan
Rajinikanth

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +0,0 @@
Astrogation
Computers
Cool
Vigilance
Mechanics
Melee
Perception
Piloting-space
Ranged-heavy
Ranged-light
Athletics
Coercion
Coordination
Charm
Deceptiono
Medicine
Negotiation
Piloting-planetary
Stealth
Skullduggery
Brawl
Discipline
Gunnery
Core-worlds
Outer-rim
Underworld
Leadership
Lore
Resilience
Streetwise
Survival
Xenology