📝 Commenting and formatting

This commit is contained in:
NikolajDanger
2020-07-29 10:38:37 +02:00
parent 94c6289cc1
commit ef434ecee8
12 changed files with 260 additions and 220 deletions

View File

@ -8,38 +8,28 @@ import string
import json import json
import random import random
import funcs from funcs import *
funcs.makeFiles() commandPrefix = "!"
funcs.shuffle()
# Gets secret bot token # Blackjack shuffle variables
with open("token.txt","r") as f: blackjackMinCards = 50
token = f.read().replace("\n","") blackjackDecks = 4
client = discord.Client() # Variable for reacting to messages
meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"]
# Logs in async def parseCommands(message,content):
@client.event # Sends the contents of a help file, as specified by the message.
async def on_ready(): if content.startswith("help"):
funcs.logThis("Logged in as "+client.user.name+", "+str(client.user.id)) if content == "help" or content == "help ":
game = discord.Game("Some weeb shit")
await client.change_presence(activity=game)
# Reads messages and tests if they are Gwendolyn commands
@client.event
async def on_message(message):
# Sends the contents of "help.txt"
if message.content.lower().startswith("!help"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
if message.content.lower() == "!help" or message.content.lower() == "!help ":
with codecs.open("resources/help/help.txt",encoding="utf-8") as f: with codecs.open("resources/help/help.txt",encoding="utf-8") as f:
text = f.read() text = f.read()
em = discord.Embed(title = "Help", description = text,colour = 0x59f442) em = discord.Embed(title = "Help", description = text,colour = 0x59f442)
await message.channel.send(embed = em) await message.channel.send(embed = em)
else: else:
command = message.content.lower().replace(" ","-").replace("!","") command = content.replace(" ","-")
funcs.logThis("Looking for "+command+".txt") logThis("Looking for "+command+".txt")
try: try:
with codecs.open("resources/help/"+command+".txt",encoding="utf-8") as f: with codecs.open("resources/help/"+command+".txt",encoding="utf-8") as f:
text = f.read() text = f.read()
@ -49,13 +39,12 @@ async def on_message(message):
await message.channel.send("Couldn't find help for that command") await message.channel.send("Couldn't find help for that command")
# Logs whatever you write in the message # Logs whatever you write in the message
if message.content.lower().startswith("!log "): if content.startswith("log "):
funcs.logThis(message.content.lower().replace("!log ","")) logThis(content.replace("log ",""))
# Stops the bot # Stops the bot
elif message.content.lower().startswith("!stop"): elif content.startswith("stop"):
if message.author.display_name == "Nikolaj": if message.author.display_name == "Nikolaj":
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send("Logging out...") await message.channel.send("Logging out...")
with open("resources/games/games.json","r") as f: with open("resources/games/games.json","r") as f:
@ -70,31 +59,28 @@ async def on_message(message):
await client.logout() await client.logout()
else: else:
funcs.logThis(message.author.display_name+" tried to run "+message.content) logThis(message.author.display_name+" tried to run stop me!")
await message.channel.send("I don't think I will, "+message.author.display_name) await message.channel.send("I don't think I will, "+message.author.display_name)
# Does a hello with the helloFunc function from funcs/gwendolynFuncs.py # Does a hello with the helloFunc function from funcs/gwendolynpy
elif message.content.lower().startswith("!hello"): elif content.startswith("hello"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send(funcs.helloFunc(message.author.display_name)) await message.channel.send(helloFunc(message.author.display_name))
# Rolls dice with the roll_dice function from funcs/roll/dice.py # Rolls dice with the roll_dice function from funcs/roll/dice.py
elif message.content.lower().startswith("!roll"): elif content.startswith("roll"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") if content == "roll" or content == "roll ":
if message.content.lower() == "!roll" or message.content.lower() == "!roll ": await message.channel.send(roll_dice(message.author.display_name))
await message.channel.send(funcs.roll_dice(message.author.display_name))
else: else:
await message.channel.send(funcs.roll_dice(message.author.display_name, message.content.lower().replace("!roll",""))) await message.channel.send(roll_dice(message.author.display_name, content.replace("roll","")))
# Looks up a spell with the spellFunc function from funcs/lookup/lookupFuncs.py # Looks up a spell with the spellFunc function from funcs/lookup/lookuppy
elif message.content.lower().startswith("!spell "): elif content.startswith("spell "):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") await message.channel.send(spellFunc(cap(content.replace("spell",""))))
await message.channel.send(funcs.spellFunc(message.content))
# Looks up a monster with the monsterFuncs() from funcs/lookup/lookupFuncs.py # Looks up a monster with the monsterFuncs() from funcs/lookup/lookuppy
elif message.content.lower().startswith("!monster "): elif content.startswith("monster "):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") title, text1, text2, text3, text4, text5 = monsterFunc(cap(content.replace("monster","")))
title, text1, text2, text3, text4, text5 = funcs.monsterFunc(message.content)
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF) em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
# Sends the received information. Seperates into seperate messages if # Sends the received information. Seperates into seperate messages if
@ -138,22 +124,19 @@ async def on_message(message):
await message.channel.send(embed = em5_2) await message.channel.send(embed = em5_2)
# Sends an image of the Senkulpa map # Sends an image of the Senkulpa map
elif message.content.lower().startswith("!map"): elif content.startswith("map"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
await message.channel.send("https://i.imgur.com/diMXXJs.jpg") await message.channel.send("https://i.imgur.com/diMXXJs.jpg")
# Finds a random image on the internet with the imageFuncs function from # Finds a random image on the internet with the imageFuncs function from
# funcs/gwendolynFuncs.py # funcs/gwendolynpy
elif message.content.lower().startswith("!image"): elif content.startswith("image"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") await message.channel.send(imageFunc())
await message.channel.send(funcs.imageFunc())
# Sends information about a random movie with the movieFunc function from # Sends information about a random movie with the movieFunc function from
# funcs/other/movie.py # funcs/other/movie.py
elif message.content.lower().startswith("!movie"): elif content.startswith("movie"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"")
async with message.channel.typing(): async with message.channel.typing():
title, plot, cover, cast = funcs.movieFunc() title, plot, cover, cast = movieFunc()
if title == "error": if title == "error":
await message.channel.send("An error occurred. Try again") await message.channel.send("An error occurred. Try again")
else: else:
@ -163,50 +146,44 @@ async def on_message(message):
await message.channel.send(embed = embed) await message.channel.send(embed = embed)
# Generates a random name with the nameGen function from funcs/other/generators.py # Generates a random name with the nameGen function from funcs/other/generators.py
elif message.content.lower().startswith("!name"): elif content.startswith("name"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") await message.channel.send(nameGen())
await message.channel.send(funcs.nameGen())
# Generates a random tavern name with the tavernGen function from funcs/other/generators.py # Generates a random tavern name with the tavernGen function from funcs/other/generators.py
elif message.content.lower().startswith("!tavern"): elif content.startswith("tavern"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") await message.channel.send(tavernGen())
await message.channel.send(funcs.tavernGen())
# Changes the "Playing this game" thing in Discord # Changes the "Playing this game" thing in Discord
elif message.content.lower().startswith("!game "): elif content.startswith("game "):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") gamePlaying = cap(content.replace("game ",""))
gamePlaying = funcs.cap(message.content.lower().replace("!game ",""))
game = discord.Game(gamePlaying) game = discord.Game(gamePlaying)
await client.change_presence(activity=game) await client.change_presence(activity=game)
# Rolls star wars dice with the parseRoll function from funcs/swfuncs/swroll.py # Rolls star wars dice with the parseRoll function from funcs/swfuncs/swroll.py
elif message.content.lower().startswith("!swroll"): elif content.startswith("swroll"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") command = cap(content.replace("swroll",""))
command = funcs.cap(message.content.lower().replace("!swroll","")) newMessage = parseRoll(message.author.display_name,command)
newMessage = funcs.parseRoll(message.author.display_name,command)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
# Deals with Destiny Points and stuff # Deals with Destiny Points and stuff
elif message.content.lower().startswith("!swd"): elif content.startswith("swd"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") command = content.replace("swd","")
command = message.content.lower().replace("!swd","") newMessage = parseDestiny(message.author.display_name,command)
newMessage = funcs.parseDestiny(message.author.display_name,command)
messageList = newMessage.split("\n") messageList = newMessage.split("\n")
for messageItem in messageList: for messageItem in messageList:
await message.channel.send(messageItem) await message.channel.send(messageItem)
# Rolls for critical injuries # Rolls for critical injuries
elif message.content.lower().startswith("!swcrit"): elif content.startswith("swcrit"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") command = content.replace("swcrit","").replace(" ","").replace("+","")
command = message.content.lower().replace("!swcrit","").replace(" ","").replace("+","")
if command == "": if command == "":
command = 0 command = 0
try: try:
newMessage = funcs.critRoll(int(command)) newMessage = critRoll(int(command))
except: except:
newMessage = "Try using a number, stupid" newMessage = "Try using a number, stupid"
@ -216,10 +193,9 @@ async def on_message(message):
# Accesses and changes character sheet data with the parseChar function # Accesses and changes character sheet data with the parseChar function
# from funcs/swfuncs/swchar.py # from funcs/swfuncs/swchar.py
elif message.content.lower().startswith("!swchar") or message.content.lower().startswith("!sw"): elif content.startswith("swchar") or content.startswith("sw"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") command = string.capwords(content.replace("swchar","").replace("sw","").replace("+","+ ").replace("-","- ").replace(",",", "))
command = string.capwords(message.content.lower().replace("!swchar","").replace("!sw","").replace("+","+ ").replace("-","- ").replace(",",", ")) title, desc = parseChar(message.author.display_name,command)
title, desc = funcs.parseChar(message.author.display_name,command)
if title != "": if title != "":
em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF) em1 = discord.Embed(title = title, description = desc, colour=0xDEADBF)
await message.channel.send(embed = em1) await message.channel.send(embed = em1)
@ -228,13 +204,12 @@ async def on_message(message):
# Searches for a specific page on the Senkulpa Wiki # Searches for a specific page on the Senkulpa Wiki
elif message.content.lower().startswith("!wiki "): elif content.startswith("wiki "):
async with message.channel.typing(): async with message.channel.typing():
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") command = string.capwords(content.replace("wiki ",""))
command = string.capwords(message.content.lower().replace("!wiki ","")) title, content, thumbnail = findWikiPage(command)
title, content, thumbnail = funcs.findWikiPage(command)
if title != "": if title != "":
funcs.logThis("Sending the embedded message") logThis("Sending the embedded message")
content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")" content += "\n[Læs mere](https://senkulpa.fandom.com/da/wiki/"+title.replace(" ","_")+")"
embed = discord.Embed(title = title, description = content, colour=0xDEADBF) embed = discord.Embed(title = title, description = content, colour=0xDEADBF)
if thumbnail != "": if thumbnail != "":
@ -246,10 +221,9 @@ async def on_message(message):
# Runs a trivia game # Runs a trivia game
elif message.content.lower().startswith("!trivia"): elif content.startswith("trivia"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") if content == "trivia" or content == "trivia ":
if message.content.lower() == "!trivia" or message.content.lower() == "!trivia ": question, answers, correctAnswer = triviaStart(str(message.channel))
question, answers, correctAnswer = funcs.triviaStart(str(message.channel))
if answers != "": if answers != "":
results = "**"+question+"**\n" results = "**"+question+"**\n"
for answer in range(len(answers)): for answer in range(len(answers)):
@ -259,7 +233,7 @@ async def on_message(message):
await asyncio.sleep(60) await asyncio.sleep(60)
funcs.triviaCountPoints(str(message.channel)) triviaCountPoints(str(message.channel))
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -268,64 +242,65 @@ async def on_message(message):
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4) json.dump(data,f,indent=4)
funcs.logThis("Time's up for the trivia question in "+str(message.channel)) logThis("Time's up for the trivia question in "+str(message.channel))
await message.channel.send("Time's up! The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck") await message.channel.send("Time's up The answer was \""+chr(correctAnswer)+") "+answers[correctAnswer-97]+"\". Anyone who answered that has gotten 1 GwendoBuck")
else: else:
await message.channel.send(question) await message.channel.send(question)
elif message.content.lower().startswith("!trivia "): elif content.startswith("trivia "):
command = message.content.lower().replace("!trivia ","") command = content.replace("trivia ","")
response = funcs.triviaOtherThing(message.author.display_name.lower(),str(message.channel),command) response = triviaAnswer(message.author.display_name.lower(),str(message.channel),command)
if response.startswith("Locked in "): if response.startswith("Locked in "):
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
await message.channel.send(response) await message.channel.send(response)
else: else:
funcs.logThis("I didn't understand that") logThis("I didn't understand that")
await message.channel.send("I didn't understand that") await message.channel.send("I didn't understand that")
#Checks your GwendoBucks balance # Checks your GwendoBucks balance
elif message.content.lower().startswith("!balance"): elif content.startswith("balance"):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") response = checkBalance(message.author.display_name.lower())
response = funcs.checkBalance(message.author.display_name.lower())
if response == 1: if response == 1:
new_message = message.author.display_name + " has " + str(response) + " GwendoBuck" new_message = message.author.display_name + " has " + str(response) + " GwendoBuck"
else: else:
new_message = message.author.display_name + " has " + str(response) + " GwendoBucks" new_message = message.author.display_name + " has " + str(response) + " GwendoBucks"
await message.channel.send(new_message) await message.channel.send(new_message)
#gives money to other player # Gives money to other player
elif message.content.lower().startswith("!give "): elif content.startswith("give "):
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") commands = content.split(" ")
commands = message.content.lower().split(" ")
if len(commands) >= 3: if len(commands) >= 3:
try: try:
amount = int(commands[2]) amount = int(commands[2])
response = funcs.giveMoney(message.author.display_name.lower(),commands[1],amount) response = giveMoney(message.author.display_name.lower(),commands[1],amount)
await message.channel.send(response) await message.channel.send(response)
except: except:
funcs.logThis("I didn't quite understand that") logThis("I didn't quite understand that")
await message.channel.send("I didn't quite understand that") await message.channel.send("I didn't quite understand that")
else: else:
funcs.logThis("I didn't understand that") logThis("I didn't understand that")
await message.channel.send("I didn't understand that") await message.channel.send("I didn't understand that")
elif message.content.lower().startswith("!blackjack"): # Runs a game of Blackjack
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") elif content.startswith("blackjack"):
if message.content.lower() == "!blackjack" or message.content.lower() == "!blackjack ": # Starts the game
new_message = funcs.blackjackStart(str(message.channel)) if content == "blackjack" or content == "blackjack ":
new_message = blackjackStart(str(message.channel))
if new_message == "started": if new_message == "started":
cardsLeft = 0 cardsLeft = 0
with open("resources/games/blackjackCards.txt","r") as f: with open("resources/games/blackjackCards.txt","r") as f:
for line in f: for line in f:
cardsLeft += 1 cardsLeft += 1
if cardsLeft < 50: # Shuffles if not enough cards
funcs.shuffle() if cardsLeft < blackjackMinCards:
blackjackShuffle(blackjackDecks)
logThis("Shuffling the blackjack deck...")
await message.channel.send("Shuffling the deck...") await message.channel.send("Shuffling the deck...")
new_message = "Blackjack game started. Use \"!blackjack bet [amount]\" to enter the game within the next 30 seconds." 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) await message.channel.send(new_message)
old_image = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel)+".png")) old_image = await message.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(message.channel)+".png"))
@ -339,8 +314,9 @@ async def on_message(message):
gamedone = True gamedone = True
await message.channel.send("No one entered the game. Ending the game.") await message.channel.send("No one entered the game. Ending the game.")
# Loop of game rounds
while gamedone == False: while gamedone == False:
new_message, allStanding, gamedone = funcs.blackjackContinue(str(message.channel)) new_message, allStanding, gamedone = blackjackContinue(str(message.channel))
if new_message != "": if new_message != "":
await message.channel.send(new_message) await message.channel.send(new_message)
if gamedone == False: if gamedone == False:
@ -351,82 +327,109 @@ async def on_message(message):
else: else:
await asyncio.sleep(30) await asyncio.sleep(30)
new_message = funcs.blackjackFinish(str(message.channel)) new_message = blackjackFinish(str(message.channel))
await message.channel.send(new_message) await message.channel.send(new_message)
else: else:
await message.channel.send(new_message) await message.channel.send(new_message)
elif message.content.lower().startswith("!blackjack bet"):
commands = message.content.lower().split(" ") # Entering game and placing bet
elif content.startswith("blackjack bet"):
commands = content.split(" ")
try: try:
amount = int(commands[2]) amount = int(commands[2])
except: except:
funcs.logThis("I didn't understand that") logThis("I didn't understand that")
response = "I didn't understand that" response = "I didn't understand that"
else: else:
response = funcs.blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount) response = blackjackPlayerDrawHand(str(message.channel),message.author.display_name,amount)
await message.channel.send(response) await message.channel.send(response)
elif message.content.lower().startswith("!blackjack hit"): # Hitting
if message.content.lower() == "!blackjack hit" or message.content.lower() == "!blackjack hit ": elif content.startswith("blackjack hit"):
response = funcs.blackjackHit(str(message.channel),message.author.display_name) if content == "blackjack hit" or content == "blackjack hit ":
response = blackjackHit(str(message.channel),message.author.display_name)
else: else:
commands = message.content.lower().split(" ") commands = content.split(" ")
try: try:
handNumber = int(commands[2]) handNumber = int(commands[2])
except: except:
handNumber = 0 handNumber = 0
response = funcs.blackjackHit(str(message.channel),message.author.display_name,handNumber) response = blackjackHit(str(message.channel),message.author.display_name,handNumber)
if response == "accept": if response == "accept":
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
await message.channel.send(response) await message.channel.send(response)
# Standing
elif message.content.lower().startswith("!blackjack stand"): elif content.startswith("blackjack stand"):
response = funcs.blackjackStand(str(message.channel),message.author.display_name,0) response = blackjackStand(str(message.channel),message.author.display_name,0)
if response == "accept": if response == "accept":
await message.add_reaction("👍") await message.add_reaction("👍")
else: else:
await message.channel.send(response) await message.channel.send(response)
elif message.content.lower().startswith("!blackjack double"): # Doubling bet
if message.content.lower() == "!blackjack hit" or message.content.lower() == "!blackjack hit ": elif content.startswith("blackjack double"):
response = funcs.blackjackDouble(str(message.channel),message.author.display_name) if content == "blackjack hit" or content == "blackjack hit ":
response = blackjackDouble(str(message.channel),message.author.display_name)
else: else:
commands = message.content.lower().split(" ") commands = content.split(" ")
try: try:
handNumber = int(commands[2]) handNumber = int(commands[2])
except: except:
handNumber = 0 handNumber = 0
response = funcs.blackjackDouble(str(message.channel),message.author.display_name,handNumber) response = blackjackDouble(str(message.channel),message.author.display_name,handNumber)
await message.channel.send(response) await message.channel.send(response)
elif message.content.lower().startswith("!blackjack split"): # Splitting hand
response = funcs.blackjackSplit(str(message.channel),message.author.display_name) elif content.startswith("blackjack split"):
response = blackjackSplit(str(message.channel),message.author.display_name)
await message.channel.send(response) await message.channel.send(response)
else: else:
await message.channel.send("I didn't quite understand that") await message.channel.send("I didn't quite understand that")
elif message.content.lower().startswith("!fourinarow"): # Runs a game of four in a row
funcs.logThis(message.author.display_name+" ran \""+message.content+"\"") elif content.startswith("fourinarow"):
response, showImage = funcs.decipherCommand(message.content.lower().replace("!fourinarow",""),str(message.channel),message.author.display_name) response, showImage = parseFourInARow(content.replace("fourinarow",""),str(message.channel),message.author.display_name)
await message.channel.send(response) await message.channel.send(response)
funcs.logThis(response) logThis(response)
if showImage: if showImage:
await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png")) await message.channel.send(file = discord.File("resources/games/4InARowBoards/board"+str(message.channel)+".png"))
# Makes files if they don't exist yet
makeFiles()
# Shuffling cards
blackjackShuffle(4)
# Gets secret bot token
with open("token.txt","r") as f:
token = f.read().replace("\n","")
client = discord.Client()
# Logs in
@client.event
async def on_ready():
logThis("Logged in as "+client.user.name+", "+str(client.user.id))
game = discord.Game("Some weeb shit")
await client.change_presence(activity=game)
# Reads messages and tests if they are Gwendolyn commands
@client.event
async def on_message(message):
content = message.content
if content.startswith(commandPrefix):
logThis(message.author.display_name+" ran \""+content+"\"")
await parseCommands(message,content.lower()[1:])
# Is a bit sassy sometimes # Is a bit sassy sometimes
meanWords = ["stupid", "bitch", "fuck", "dumb", "idiot"] if ("gwendolyn" in message.content.lower() or message.content.startswith(commandPrefix)) and any(x in message.content.lower() for x in meanWords) and "ikke" not in message.content.lower() and "not" not in message.content.lower():
if ("gwendolyn" in message.content.lower() or message.content.startswith("!")) and any(x in message.content.lower() for x in meanWords) and "ikke" not in message.content.lower() and "not" not in message.content.lower(): logThis(message.author.display_name+" was a bit mean")
funcs.logThis(message.author.display_name+" was a bit mean")
emoji = random.choice(["😠", "🖕", "👎"]) emoji = random.choice(["😠", "🖕", "👎"])
await message.add_reaction(emoji) await message.add_reaction(emoji)

View File

@ -1,11 +1,11 @@
from .gwendolynFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple from .miscFuncs import helloFunc, cap, imageFunc, logThis, findWikiPage, makeFiles, replaceMultiple
from .swfuncs import parseChar, parseRoll, parseDestiny, critRoll from .swfuncs import *
from .lookup import spellFunc, monsterFunc from .lookup import *
from .other import nameGen, tavernGen, movieFunc from .other import *
from .games import triviaStart, triviaOtherThing, triviaCountPoints, checkBalance, addMoney, giveMoney, shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackStand, blackjackHit,blackjackDouble,blackjackSplit, decipherCommand from .games import *
from .roll import roll_dice from .roll import *

View File

@ -1,4 +1,4 @@
from .money import checkBalance, giveMoney, addMoney from .money import checkBalance, giveMoney, addMoney
from .trivia import triviaCountPoints, triviaStart, triviaOtherThing from .trivia import triviaCountPoints, triviaStart, triviaAnswer
from .blackjack import shuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit from .blackjack import blackjackShuffle, blackjackStart, blackjackPlayerDrawHand, blackjackContinue, blackjackFinish, blackjackHit, blackjackStand, blackjackDouble, blackjackSplit
from .fourInARow import decipherCommand from .fourInARow import parseFourInARow

View File

@ -7,15 +7,14 @@ from shutil import copyfile
from funcs import logThis, replaceMultiple from funcs import logThis, replaceMultiple
from . import money, blackjackDraw from . import money, blackjackDraw
deckAmount = 4 # Shuffles the blackjack cards
def blackjackShuffle(decks):
def shuffle():
logThis("Shuffling the blackjack deck") logThis("Shuffling the blackjack deck")
with open("resources/games/deckofCards.txt","r") as f: with open("resources/games/deckofCards.txt","r") as f:
deck = f.read() deck = f.read()
allDecks = deck.split("\n") * 4 allDecks = deck.split("\n") * decks
random.shuffle(allDecks) random.shuffle(allDecks)
data = "\n".join(allDecks) data = "\n".join(allDecks)
@ -24,6 +23,7 @@ def shuffle():
return return
# Calculates the value of a blackjack hand
def calcHandValue(hand : list): def calcHandValue(hand : list):
logThis("Calculating hand value") logThis("Calculating hand value")
values = [0] values = [0]
@ -51,13 +51,13 @@ def calcHandValue(hand : list):
return handValue return handValue
# Draws a card from the deck
def drawCard(): def drawCard():
logThis("drawing a card") logThis("drawing a card")
with open("resources/games/blackjackCards.txt","r") as f: with open("resources/games/blackjackCards.txt","r") as f:
cards = f.read().split("\n") cards = f.read().split("\n")
drawnCard = cards[0] drawnCard = cards.pop(0)
cards = cards[1:]
data = "\n".join(cards) data = "\n".join(cards)
with open("resources/games/blackjackCards.txt","w") as f: with open("resources/games/blackjackCards.txt","w") as f:
@ -65,6 +65,7 @@ def drawCard():
return drawnCard return drawnCard
# Dealer draws a card and checks if they should draw another one
def dealerDraw(channel): def dealerDraw(channel):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -85,6 +86,7 @@ def dealerDraw(channel):
return done return done
# Goes to the next round and calculates some stuff
def blackjackContinue(channel): def blackjackContinue(channel):
logThis("Continuing blackjack game") logThis("Continuing blackjack game")
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
@ -163,6 +165,7 @@ def blackjackContinue(channel):
firstRoundMessage = "" firstRoundMessage = ""
return "You have 30 seconds to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done return "You have 30 seconds to either hit or stand with \"!blackjack hit\" or \"!blackjack stand\""+firstRoundMessage+". It's assumed you're standing if you don't make a choice.", False, done
# When players try to hit
def blackjackHit(channel,user,handNumber = 0): def blackjackHit(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -216,6 +219,7 @@ def blackjackHit(channel,user,handNumber = 0):
return "You can't hit before you see your cards" return "You can't hit before you see your cards"
# When players try to double down
def blackjackDouble(channel,user,handNumber = 0): def blackjackDouble(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -287,6 +291,7 @@ def blackjackDouble(channel,user,handNumber = 0):
logThis(user+" tried to double on the 0th round") logThis(user+" tried to double on the 0th round")
return "You can't double down before you see your cards" return "You can't double down before you see your cards"
# When players try to stand
def blackjackStand(channel,user,handNumber = 0): def blackjackStand(channel,user,handNumber = 0):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -310,6 +315,7 @@ def blackjackStand(channel,user,handNumber = 0):
logThis(user+" tried to stand on the first round") logThis(user+" tried to stand on the first round")
return "You can't stand before you see your cards" return "You can't stand before you see your cards"
# When players try to split
def blackjackSplit(channel,user): def blackjackSplit(channel,user):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -374,6 +380,7 @@ def blackjackSplit(channel,user):
logThis(user+" tried to split on the 0th round") logThis(user+" tried to split on the 0th round")
return "You can't split before you see your cards" return "You can't split before you see your cards"
# Player enters the game and draws a hand
def blackjackPlayerDrawHand(channel,user,bet): def blackjackPlayerDrawHand(channel,user,bet):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -431,6 +438,7 @@ def blackjackPlayerDrawHand(channel,user,bet):
logThis("There is no game going on in "+channel) logThis("There is no game going on in "+channel)
return "There is no game going on in this channel" return "There is no game going on in this channel"
# Starts a game of blackjack
def blackjackStart(channel:str): def blackjackStart(channel:str):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -456,6 +464,7 @@ def blackjackStart(channel:str):
logThis("There is already a blackjack game going on in "+channel) logThis("There is already a blackjack game going on in "+channel)
return "There's already a blackjack game going on. Try again in a few minutes." return "There's already a blackjack game going on. Try again in a few minutes."
# Ends the game and calculates winnings
def blackjackFinish(channel): def blackjackFinish(channel):
finalWinnings = "*Final Winnings:*\n" finalWinnings = "*Final Winnings:*\n"
@ -480,6 +489,7 @@ def blackjackFinish(channel):
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"] winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) > dealerValue: elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) > dealerValue:
winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"] winnings += 2 * data["blackjack games"][channel]["user hands"][user]["bet"]
reason = "(highest value)"
elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) == dealerValue: elif calcHandValue(data["blackjack games"][channel]["user hands"][user]["hand"]) == dealerValue:
reason = "(pushed)" reason = "(pushed)"
winnings += data["blackjack games"][channel]["user hands"][user]["bet"] winnings += data["blackjack games"][channel]["user hands"][user]["bet"]

View File

@ -4,6 +4,7 @@ import math
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from funcs import logThis from funcs import logThis
# Draws the whole thing
def drawImage(channel): def drawImage(channel):
logThis("Drawing four in a row board") logThis("Drawing four in a row board")
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
@ -29,13 +30,16 @@ def drawImage(channel):
background = Image.new("RGBA", (w,h),backgroundColor) background = Image.new("RGBA", (w,h),backgroundColor)
d = ImageDraw.Draw(background) d = ImageDraw.Draw(background)
# This whole part was the easiest way to make a rectangle with rounded corners and an outline
# - Corners:
d.ellipse([(border,border),(border+cornerSize,border+cornerSize)],fill=boardColor,outline=(0,0,0),width=outlineSize) d.ellipse([(border,border),(border+cornerSize,border+cornerSize)],fill=boardColor,outline=(0,0,0),width=outlineSize)
d.ellipse([(w-(border+cornerSize),h-(border+cornerSize)),(w-border,h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize) d.ellipse([(w-(border+cornerSize),h-(border+cornerSize)),(w-border,h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize)
d.ellipse([(border,h-(border+cornerSize)),(border+cornerSize,h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize) d.ellipse([(border,h-(border+cornerSize)),(border+cornerSize,h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize)
d.ellipse([(w-(border+cornerSize),border),(w-border,border+cornerSize)],fill=boardColor,outline=(0,0,0),width=outlineSize) d.ellipse([(w-(border+cornerSize),border),(w-border,border+cornerSize)],fill=boardColor,outline=(0,0,0),width=outlineSize)
# - Rectangle:
d.rectangle([(border+math.floor(cornerSize/2),border),(w-(border+math.floor(cornerSize/2)),h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize) d.rectangle([(border+math.floor(cornerSize/2),border),(w-(border+math.floor(cornerSize/2)),h-border)],fill=boardColor,outline=(0,0,0),width=outlineSize)
d.rectangle([(border,border+math.floor(cornerSize/2)),(w-border,h-(border+math.floor(cornerSize/2)))],fill=boardColor,outline=(0,0,0),width=outlineSize) d.rectangle([(border,border+math.floor(cornerSize/2)),(w-border,h-(border+math.floor(cornerSize/2)))],fill=boardColor,outline=(0,0,0),width=outlineSize)
# - Removing outline on the inside:
d.rectangle([(border+math.floor(cornerSize/2),border+math.floor(cornerSize/2)),(w-(border+math.floor(cornerSize/2)),h-(border+math.floor(cornerSize/2)))],fill=boardColor) d.rectangle([(border+math.floor(cornerSize/2),border+math.floor(cornerSize/2)),(w-(border+math.floor(cornerSize/2)),h-(border+math.floor(cornerSize/2)))],fill=boardColor)
d.ellipse([(border+outlineSize,border+outlineSize),(border+cornerSize-outlineSize,border+cornerSize-outlineSize)],fill=boardColor) d.ellipse([(border+outlineSize,border+outlineSize),(border+cornerSize-outlineSize,border+cornerSize-outlineSize)],fill=boardColor)
d.ellipse([(w-(border+cornerSize)+outlineSize,h-(border+cornerSize)+outlineSize),(w-border-outlineSize,h-border-outlineSize)],fill=boardColor) d.ellipse([(w-(border+cornerSize)+outlineSize,h-(border+cornerSize)+outlineSize),(w-border-outlineSize,h-border-outlineSize)],fill=boardColor)

View File

@ -2,6 +2,7 @@ import json
from . import draw4InARow from . import draw4InARow
# Starts the game
def fourInARowStart(channel): def fourInARowStart(channel):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -21,7 +22,7 @@ def fourInARowStart(channel):
else: else:
return "There's already a 4 in a row game going on in this channel", False return "There's already a 4 in a row game going on in this channel", False
# Places a piece at the lowest available point in a specific column
def placePiece(channel : str,player : int,column : int): def placePiece(channel : str,player : int,column : int):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -51,8 +52,8 @@ def placePiece(channel : str,player : int,column : int):
return "There's no game in this channel", False return "There's no game in this channel", False
# Parses command
def decipherCommand(command, channel, user): def parseFourInARow(command, channel, user):
if command == "" or command == " ": if command == "" or command == " ":
return fourInARowStart(channel) return fourInARowStart(channel)
elif command.startswith(" place"): elif command.startswith(" place"):

View File

@ -2,6 +2,7 @@ import json
from funcs import logThis from funcs import logThis
# Returns the account balance for a user
def checkBalance(user): def checkBalance(user):
user = user.lower() user = user.lower()
logThis("checking "+user+"'s account balance") logThis("checking "+user+"'s account balance")
@ -12,6 +13,7 @@ def checkBalance(user):
return data["users"][user] return data["users"][user]
else: return 0 else: return 0
# Adds money to the account of a user
def addMoney(user,amount): def addMoney(user,amount):
user = user.lower() user = user.lower()
logThis("adding "+str(amount)+" to "+user+"'s account") logThis("adding "+str(amount)+" to "+user+"'s account")
@ -27,6 +29,7 @@ def addMoney(user,amount):
with open("resources/games/games.json", "w") as f: with open("resources/games/games.json", "w") as f:
json.dump(data,f,indent=4) json.dump(data,f,indent=4)
# Transfers money from one user to another
def giveMoney(user,targetUser,amount): def giveMoney(user,targetUser,amount):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -35,7 +38,7 @@ def giveMoney(user,targetUser,amount):
if data["users"][user] >= amount: if data["users"][user] >= amount:
addMoney(user,-1 * amount) addMoney(user,-1 * amount)
addMoney(targetUser,amount) addMoney(targetUser,amount)
return "Transferred the GwendoBucks" return "Transferred "+str(amount)+" GwendoBucks to "+user
else: else:
logThis("They didn't have enough GwendoBucks") logThis("They didn't have enough GwendoBucks")
return "You don't have that many GwendoBucks" return "You don't have that many GwendoBucks"

View File

@ -5,6 +5,8 @@ import random
from . import money from . import money
from funcs import logThis from funcs import logThis
# Starts a game of trivia. Downloads a question with answers, shuffles the wrong answers with the
# correct answer and returns the questions and answers. Also saves the question in the games.json file.
def triviaStart(channel : str): def triviaStart(channel : str):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
triviaFile = json.load(f) triviaFile = json.load(f)
@ -44,7 +46,8 @@ def triviaStart(channel : str):
logThis("There was already a trivia question for that channel") logThis("There was already a trivia question for that channel")
return "There's already a trivia question going on. Try again in like, a minute", "", "" return "There's already a trivia question going on. Try again in like, a minute", "", ""
def triviaOtherThing(user : str, channel : str, command : str): # Lets players answer a trivia question
def triviaAnswer(user : str, channel : str, command : str):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)
@ -66,6 +69,8 @@ def triviaOtherThing(user : str, channel : str, command : str):
else: else:
return "I didn't quite understand that" return "I didn't quite understand that"
# Adds 1 GwendoBuck to each player that got the question right and deletes question from games.json.
def triviaCountPoints(channel : str): def triviaCountPoints(channel : str):
with open("resources/games/games.json", "r") as f: with open("resources/games/games.json", "r") as f:
data = json.load(f) data = json.load(f)

View File

@ -15,12 +15,11 @@ saves = ["strength_save","dexterity_save","constitution_save","intelligence_save
abilities = ["acrobatics","animal_handling","arcana","athletics","deception","history","insight","intimidation","investigation","medicine","nature","perception","performance","persuasion","religion","sleight_of_hand","stealth","survival"] abilities = ["acrobatics","animal_handling","arcana","athletics","deception","history","insight","intimidation","investigation","medicine","nature","perception","performance","persuasion","religion","sleight_of_hand","stealth","survival"]
# Looks up a monster # Looks up a monster
def monsterFunc(content): def monsterFunc(command):
command = cap(content.lower().replace("!monster ",""))
logThis("Looking up "+command) logThis("Looking up "+command)
# 1-letter monsters don't exist # 1-letter monsters don't exist
if len(content.lower().split()) < 2: if len(command) < 2:
logThis("Monster doesn't exist in database") logThis("Monster doesn't exist in database")
return("I don't know that monster...","","","","","") return("I don't know that monster...","","","","","")
else: else:
@ -122,8 +121,7 @@ def monsterFunc(content):
return("I don't know that monster...","","","","","") return("I don't know that monster...","","","","","")
# Looks up a spell # Looks up a spell
def spellFunc(content): def spellFunc(command):
command = cap(content.lower().replace("!spell ",""))
logThis("Looking up "+command) logThis("Looking up "+command)
# Opens "spells.json" # Opens "spells.json"

View File

@ -183,10 +183,17 @@ def makeFiles():
finally: finally:
f.close() f.close()
# Creates the blackjacktables foulder if it doesn't exist
if os.path.isdir("resources/games/blackjackTables") == False: if os.path.isdir("resources/games/blackjackTables") == False:
os.makedirs("resources/games/blackjackTables") os.makedirs("resources/games/blackjackTables")
logThis("The tables directory didn't exist") logThis("The tables directory didn't exist")
# Creates the 4InARowBoards foulder if it doesn't exist
if os.path.isdir("resources/games/4InARowBoards") == False:
os.makedirs("resources/games/4InARowBoards")
logThis("The tables directory didn't exist")
# Replaces multiple things with the same thing
def replaceMultiple(mainString, toBeReplaces, newString): def replaceMultiple(mainString, toBeReplaces, newString):
# Iterate over the strings to be replaced # Iterate over the strings to be replaced
for elem in toBeReplaces : for elem in toBeReplaces :

View File

@ -10,6 +10,7 @@ from funcs import logThis
with open("resources/swskills.json", "r") as f: with open("resources/swskills.json", "r") as f:
skillData = json.load(f) skillData = json.load(f)
# Rolls the specified dice
def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0): def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
result = "" result = ""
diceResult = [] diceResult = []
@ -50,6 +51,7 @@ def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int
return result, diceResult return result, diceResult
# Lets dice cancel each other out
def simplify(result : str): def simplify(result : str):
logThis("Simplifying "+result) logThis("Simplifying "+result)
simp = "" simp = ""
@ -75,116 +77,119 @@ def simplify(result : str):
return simp return simp
# Returns emoji that symbolize the dice results
def diceResultToEmoji(diceResults : list): def diceResultToEmoji(diceResults : list):
emoji = "" emoji = ""
for result in diceResults: for result in diceResults:
if result == "abiA": if result == "abiA":
emoji += "<:abil1a:695267684476125264> " emoji += "<:abil1a:695267684476125264> "
if result == "abiSA": elif result == "abiSA":
emoji += "<:abil1a1s:695267684484513842> " emoji += "<:abil1a1s:695267684484513842> "
if result == "abiS": elif result == "abiS":
emoji += "<:abil1s:695267684514005013> " emoji += "<:abil1s:695267684514005013> "
if result == "abiAA": elif result == "abiAA":
emoji += "<:abil2a:695267684547428352> " emoji += "<:abil2a:695267684547428352> "
if result == "abiSS": elif result == "abiSS":
emoji += "<:abil2s:695267684761206914> " emoji += "<:abil2s:695267684761206914> "
if result == "abi": elif result == "abi":
emoji += "<:abilbla:695267684660674602> " emoji += "<:abilbla:695267684660674602> "
if result == "profA": elif result == "profA":
emoji += "<:prof1a:695267685361123338> " emoji += "<:prof1a:695267685361123338> "
if result == "profSA": elif result == "profSA":
emoji += "<:prof1a1s:695267685067653140> " emoji += "<:prof1a1s:695267685067653140> "
if result == "profR": elif result == "profR":
emoji += "<:prof1r:695267685067522088> " emoji += "<:prof1r:695267685067522088> "
if result == "profS": elif result == "profS":
emoji += "<:prof1s:695267684899881012> " emoji += "<:prof1s:695267684899881012> "
if result == "profAA": elif result == "profAA":
emoji += "<:prof2a:695267684996218982> " emoji += "<:prof2a:695267684996218982> "
if result == "profSS": elif result == "profSS":
emoji += "<:prof2s:695267684878647327> " emoji += "<:prof2s:695267684878647327> "
if result == "prof": elif result == "prof":
emoji += "<:profbla:695267684698292235> " emoji += "<:profbla:695267684698292235> "
if result == "difF": elif result == "difF":
emoji += "<:dif1f:695267684924915804> " emoji += "<:dif1f:695267684924915804> "
if result == "difH": elif result == "difH":
emoji += "<:dif1h:695267684908138506> " emoji += "<:dif1h:695267684908138506> "
if result == "difFH": elif result == "difFH":
emoji += "<:dif1h1f:695267684908269678> " emoji += "<:dif1h1f:695267684908269678> "
if result == "difFF": elif result == "difFF":
emoji += "<:dif2f:695267684924784680> " emoji += "<:dif2f:695267684924784680> "
if result == "difHH": elif result == "difHH":
emoji += "<:dif2h:695267685071585340> " emoji += "<:dif2h:695267685071585340> "
if result == "dif": elif result == "dif":
emoji += "<:difbla:695267685000544276> " emoji += "<:difbla:695267685000544276> "
if result == "chaD": elif result == "chaD":
emoji += "<:cha1d:695267684962533447> " emoji += "<:cha1d:695267684962533447> "
if result == "chaF": elif result == "chaF":
emoji += "<:cha1f:695267684601954346> " emoji += "<:cha1f:695267684601954346> "
if result == "chaH": elif result == "chaH":
emoji += "<:cha1h:695267685046681620> " emoji += "<:cha1h:695267685046681620> "
if result == "chaFH": elif result == "chaFH":
emoji += "<:cha1h1f:695267685063327784> " emoji += "<:cha1h1f:695267685063327784> "
if result == "chaFF": elif result == "chaFF":
emoji += "<:cha2f:695267684832641097> " emoji += "<:cha2f:695267684832641097> "
if result == "chaHH": elif result == "chaHH":
emoji += "<:cha2h:695267684631183381> " emoji += "<:cha2h:695267684631183381> "
if result == "cha": elif result == "cha":
emoji += "<:chabla:695267684895686787> " emoji += "<:chabla:695267684895686787> "
if result == "booA": elif result == "booA":
emoji += "<:boo1a:695267684975116329> " emoji += "<:boo1a:695267684975116329> "
if result == "booSA": elif result == "booSA":
emoji += "<:boo1a1s:695267684970922024> " emoji += "<:boo1a1s:695267684970922024> "
if result == "booS": elif result == "booS":
emoji += "<:boo1s:695267684979441714> " emoji += "<:boo1s:695267684979441714> "
if result == "booAA": elif result == "booAA":
emoji += "<:boo2a:695267685100945488> " emoji += "<:boo2a:695267685100945488> "
if result == "boo": elif result == "boo":
emoji += "<:boobla:695267684757012550> " emoji += "<:boobla:695267684757012550> "
if result == "setbF": elif result == "setbF":
emoji += "<:set1f:695267685054939197> " emoji += "<:set1f:695267685054939197> "
if result == "setbH": elif result == "setbH":
emoji += "<:set1h:695267685147082802> " emoji += "<:set1h:695267685147082802> "
if result == "setb": elif result == "setb":
emoji += "<:setbla:695267685151408169> " emoji += "<:setbla:695267685151408169> "
if result == "forceB": elif result == "forceB":
emoji += "<:for1b:695267684593434677> " emoji += "<:for1b:695267684593434677> "
if result == "forceL": elif result == "forceL":
emoji += "<:for1l:695267684606148640> " emoji += "<:for1l:695267684606148640> "
if result == "forceBB": elif result == "forceBB":
emoji += "<:for2b:695267684903944303> " emoji += "<:for2b:695267684903944303> "
if result == "forceLL": elif result == "forceLL":
emoji += "<:for2l:695267684992024626> " emoji += "<:for2l:695267684992024626> "
return emoji return emoji
# Returns emoji that symbolize the results of the dice rolls
def resultToEmoji(result : str): def resultToEmoji(result : str):
emoji = "" emoji = ""
for char in result: for char in result:
if char == 'S': if char == 'S':
emoji += "<:success:690971244971163718> " emoji += "<:success:690971244971163718> "
if char == 'A': elif char == 'A':
emoji += "<:advantage:690970761611051079> " emoji += "<:advantage:690970761611051079> "
if char == 'R': elif char == 'R':
emoji += "<:swtriumph:690971267486187643> " emoji += "<:swtriumph:690971267486187643> "
if char == 'F': elif char == 'F':
emoji += "<:failure:690970957786906664> " emoji += "<:failure:690970957786906664> "
if char == 'H': elif char == 'H':
emoji += "<:threat:690971009469382656> " emoji += "<:threat:690971009469382656> "
if char == 'D': elif char == 'D':
emoji += "<:despair:690971200163414238> " emoji += "<:despair:690971200163414238> "
if char == 'L': elif char == 'L':
emoji += "<:light:691010089905029171>" emoji += "<:light:691010089905029171>"
if char == 'B': elif char == 'B':
emoji += "<:dark:691010101901000852>" emoji += "<:dark:691010101901000852>"
return emoji return emoji
# Converts emoji into letters
def emojiToResult(emoji : str): def emojiToResult(emoji : str):
result = "" result = ""
for char in emoji: for char in emoji:
@ -195,6 +200,7 @@ def emojiToResult(emoji : str):
return result return result
# Returns emoji that symbolize the dice
def diceToEmoji(dice : list): def diceToEmoji(dice : list):
emoji = "" emoji = ""
@ -215,6 +221,7 @@ def diceToEmoji(dice : list):
return emoji return emoji
# Rolls for obligation
def obligationRoll(): def obligationRoll():
logThis("Rolling for obligation") logThis("Rolling for obligation")
with open("resources/swcharacters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
@ -232,6 +239,7 @@ def obligationRoll():
return random.choice(table) return random.choice(table)
# Rolls for critical injury
def critRoll(addington : int): def critRoll(addington : int):
dd = "<:difficulty:690973992470708296>" dd = "<:difficulty:690973992470708296>"
sd = "<:setback:690972157890658415>" sd = "<:setback:690972157890658415>"
@ -283,6 +291,7 @@ def critRoll(addington : int):
return "Roll: "+str(roll)+"\nInjury:\n"+results return "Roll: "+str(roll)+"\nInjury:\n"+results
# Parses the command into something the other functions understand
def parseRoll(user : str,cmd : str = ""): def parseRoll(user : str,cmd : str = ""):
cmd = re.sub(' +',' ',cmd.upper()) + " " cmd = re.sub(' +',' ',cmd.upper()) + " "
if cmd[0] == " ": if cmd[0] == " ":
@ -296,7 +305,7 @@ def parseRoll(user : str,cmd : str = ""):
if string.capwords(commands[0]) == "Obligations": if string.capwords(commands[0]) == "Obligations":
return obligationRoll() return obligationRoll()
elif string.capwords(commands[0]) in skillData: elif string.capwords(commands[0]) in skillData:
logThis("Oh look! This guy has skills!") logThis("Oh look! This guy has skills!")
if swchar.userHasChar: if swchar.userHasChar:

View File

@ -16,16 +16,16 @@
**!tavern** - Genererer en tilfældig tavern. **!tavern** - Genererer en tilfældig tavern.
**!trivia** - Lader dig spille et spil trivia, hvor du kan tjene GwendoBucks.
**!balance** - Viser dig hvor mange GwendoBucks du har.
**!give** - Lader dig give GwendoBucks til andre. **!give** - Lader dig give GwendoBucks til andre.
**!swchar** - Lader dig lave en Star Wars karakter. **!swchar** - Lader dig lave en Star Wars karakter.
**!swroll** - Lader dig rulle Star Wars terninger. **!swroll** - Lader dig rulle Star Wars terninger.
**!balance** - Viser dig hvor mange GwendoBucks du har.
**!blackjack** - Lader dig spille it spil blackjack. **!blackjack** - Lader dig spille it spil blackjack.
**!trivia** - Lader dig spille et spil trivia, hvor du kan tjene GwendoBucks.
Du kan få ekstra information om kommandoerne med "!help [kommando]". Du kan få ekstra information om kommandoerne med "!help [kommando]".