🧹 More refactoring

This commit is contained in:
Nikolaj
2021-08-17 18:05:41 +02:00
parent 074a06e863
commit 573d081734
31 changed files with 1971 additions and 1787 deletions

View File

@ -6,7 +6,7 @@ class StarWarsChar():
def __init__(self, bot):
self.bot = bot
def getCharName(self, user : str):
def getChar_name(self, user : str):
self.bot.log("Getting name for "+self.bot.database_funcs.get_name(user)+"'s character")
userCharacter = self.bot.database["starwars characters"].find_one({"_id":user})
@ -239,7 +239,7 @@ class StarWarsChar():
return name, text1+text2+"\n\n"+text3+divider+text4+"\n"+divider+text5+text6+text7+text8
def charData(self,user : str,cmd : str):
def char_data(self,user : str,cmd : str):
userCharacter = self.bot.database["starwars characters"].find_one({"_id":user})
key = string.capwords(cmd.split(" ")[0])
@ -508,7 +508,7 @@ class StarWarsChar():
self.bot.database["starwars characters"].delete_one({"_id":user})
await ctx.send("Character for " + self.bot.database_funcs.get_name(user) + " deleted")
else:
await ctx.send(self.replaceWithSpaces(str(self.charData(user,cmd))))
await ctx.send(self.replaceWithSpaces(str(self.char_data(user,cmd))))
if returnEmbed:
em = discord.Embed(title = title, description = text, colour=0xDEADBF)

View File

@ -52,21 +52,21 @@ class StarWarsDestiny():
if cmd == "":
self.bot.log("Retrieving destiny pool info")
with open("gwendolyn/resources/star_wars/destinyPoints.txt","rt") as f:
sendMessage = self.bot.star_wars.roll.resultToEmoji(f.read())
send_message = self.bot.star_wars.roll.resultToEmoji(f.read())
else:
commands = cmd.upper().split(" ")
if commands[0] == "N":
if len(commands) > 1:
sendMessage = self.destinyNew(int(commands[1]))
send_message = self.destinyNew(int(commands[1]))
else:
sendMessage = "You need to give an amount of players (error code 921)"
send_message = "You need to give an amount of players (error code 921)"
elif commands[0] == "U":
sendMessage = self.destinyUse(user)
send_message = self.destinyUse(user)
else:
sendMessage = "I didn't quite understand that (error code 922)"
send_message = "I didn't quite understand that (error code 922)"
messageList = sendMessage.split("\n")
await ctx.send(messageList[0])
if len(messageList) > 1:
for messageItem in messageList[1:]:
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
await ctx.channel.send(messageItem)

View File

@ -4,7 +4,7 @@ import string
import json
with open("gwendolyn/resources/star_wars/starwarsskills.json", "r") as f:
skillData = json.load(f)
skill_data = json.load(f)
class StarWarsRoll():
def __init__(self, bot):
@ -288,12 +288,12 @@ class StarWarsRoll():
characteristic = random.choice(["brawn"] * 3 + ["agility"] * 3 + ["intellect", "cunning", "presence"])
results = "**Gruesome Injury**: The target's "+characteristic+" is permanently one lower, "+dd+dd+dd+dd
sendMessage = "Roll: "+str(roll)+"\nInjury:\n"+results
send_message = "Roll: "+str(roll)+"\nInjury:\n"+results
messageList = sendMessage.split("\n")
await ctx.send(messageList[0])
if len(messageList) > 1:
for messageItem in messageList[1:]:
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
await ctx.channel.send(messageItem)
# Parses the command into something the other functions understand
@ -312,19 +312,19 @@ class StarWarsRoll():
rollParameters = [0,0,0,0,0,0,0]
if string.capwords(commands[0]) == "Obligations":
sendMessage = self.obligationRoll()
send_message = self.obligationRoll()
elif string.capwords(commands[0]) in skillData:
elif string.capwords(commands[0]) in skill_data:
self.bot.log("Oh look! This guy has skills!")
if self.bot.star_wars.character.userHasChar(user):
self.bot.log("They have a character. That much we know")
skillLevel = self.bot.star_wars.character.charData(user,"Skills " + string.capwords(commands[0]))
skillLevel = self.bot.star_wars.character.char_data(user,"Skills " + string.capwords(commands[0]))
if string.capwords(commands[0]) == "Lightsaber":
self.bot.log("The skill is lightsaber")
charLevel = self.bot.star_wars.character.charData(user,"Characteristics " + self.bot.star_wars.character.lightsaberChar(user))
charLevel = self.bot.star_wars.character.char_data(user,"Characteristics " + self.bot.star_wars.character.lightsaberChar(user))
else:
charLevel = self.bot.star_wars.character.charData(user,"Characteristics " + skillData[string.capwords(commands[0])])
charLevel = self.bot.star_wars.character.char_data(user,"Characteristics " + skill_data[string.capwords(commands[0])])
abilityDice = abs(charLevel-skillLevel)
proficiencyDice = min(skillLevel,charLevel)
@ -334,14 +334,14 @@ class StarWarsRoll():
validCommand = True
else:
self.bot.log("Okay, no they don't i guess")
sendMessage = "You don't have a user. You can make one with /starwarscharacter"
send_message = "You don't have a user. You can make one with /starwarscharacter"
elif string.capwords(commands[0]) in ["Ranged","Piloting"]:
self.bot.log("They fucked up writing the name of a ranged or piloting skill")
if string.capwords(commands[0]) == "Ranged":
sendMessage = "Did you mean \"Ranged - Heavy\" or \"Ranged - Light\" (error code 913)"
send_message = "Did you mean \"Ranged - Heavy\" or \"Ranged - Light\" (error code 913)"
else:
sendMessage = "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\" (error code 913)"
send_message = "Did you mean \"Piloting - Planetary\" or \"Piloting - Space\" (error code 913)"
else:
validCommand = True
@ -372,19 +372,19 @@ class StarWarsRoll():
simplified = self.simplify(rollResults)
name = self.bot.star_wars.character.getCharName(user)
name = self.bot.star_wars.character.getChar_name(user)
self.bot.log("Returns results and simplified results")
if simplified == "":
sendMessage = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\nEverything cancels out!"
send_message = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\nEverything cancels out!"
else:
sendMessage = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\n" + self.resultToEmoji(simplified)
send_message = name + " rolls: " + "\n" + self.diceResultToEmoji(diceResults) + "\n" + self.resultToEmoji(simplified)
messageList = sendMessage.split("\n")
await ctx.send(messageList[0])
if len(messageList) > 1:
for messageItem in messageList[1:]:
message_list = send_message.split("\n")
await ctx.send(message_list[0])
if len(message_list) > 1:
for messageItem in message_list[1:]:
if messageItem == "":
self.bot.log("Tried to send empty message")
else: