diff --git a/.gitignore b/.gitignore index 64f0d96..a1417f2 100644 --- a/.gitignore +++ b/.gitignore @@ -150,14 +150,14 @@ 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/monsters.json -resources/spells.json +resources/lookup/monsters.json +resources/lookup/spells.json gwendolynTest.py diff --git a/funcs/lookup/lookupFuncs.py b/funcs/lookup/lookupFuncs.py index 7f89060..6381340 100644 --- a/funcs/lookup/lookupFuncs.py +++ b/funcs/lookup/lookupFuncs.py @@ -24,7 +24,7 @@ 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 "name" in monster and str(command) == monster["name"]: logThis("Found it!") @@ -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"])) diff --git a/funcs/miscFuncs.py b/funcs/miscFuncs.py index cac48d7..aef30a9 100644 --- a/funcs/miscFuncs.py +++ b/funcs/miscFuncs.py @@ -138,11 +138,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() @@ -160,34 +160,34 @@ def makeFiles(): # Creates monsters.json if it doesn't exist try: - f = open("resources/monsters.json","r") + f = open("resources/lookup/monsters.json","r") except: logThis("monsters.json didn't exist. Making it now.") - with open("resources/lookupExamples.json") as f: + with open("resources/lookup/lookupExamples.json") as f: data = json.load(f)["monster"] - with open("resources/monsters.json","w") as f: + 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/spells.json","r") + f = open("resources/lookup/spells.json","r") except: logThis("spells.json didn't exist. Making it now.") - with open("resources/lookupExamples.json") as f: + with open("resources/lookup/lookupExamples.json") as f: data = json.load(f)["spell"] - with open("resources/spells.json","w") as f: + 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() diff --git a/funcs/swfuncs/swchar.py b/funcs/swfuncs/swchar.py index b18c3e6..1f09016 100644 --- a/funcs/swfuncs/swchar.py +++ b/funcs/swfuncs/swchar.py @@ -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 diff --git a/funcs/swfuncs/swdestiny.py b/funcs/swfuncs/swdestiny.py index 0ede7f9..0008508 100644 --- a/funcs/swfuncs/swdestiny.py +++ b/funcs/swfuncs/swdestiny.py @@ -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(" ") diff --git a/funcs/swfuncs/swroll.py b/funcs/swfuncs/swroll.py index 59c9192..cc71ba5 100644 --- a/funcs/swfuncs/swroll.py +++ b/funcs/swfuncs/swroll.py @@ -7,7 +7,7 @@ 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 +224,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 = [] diff --git a/resources/games.json b/resources/games.json deleted file mode 100644 index 22b4179..0000000 --- a/resources/games.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "trivia questions": {}, - "users": { - "nikolaj": 1, - "jonathanh\u00f8jlev": 6 - } -} \ No newline at end of file diff --git a/resources/lookupExamples.json b/resources/lookup/lookupExamples.json similarity index 100% rename from resources/lookupExamples.json rename to resources/lookup/lookupExamples.json diff --git a/resources/swskills.json b/resources/starWars/swskills.json similarity index 100% rename from resources/swskills.json rename to resources/starWars/swskills.json diff --git a/resources/swskills.txt b/resources/starWars/swskills.txt similarity index 100% rename from resources/swskills.txt rename to resources/starWars/swskills.txt diff --git a/resources/swtemplates.json b/resources/starWars/swtemplates.json similarity index 100% rename from resources/swtemplates.json rename to resources/starWars/swtemplates.json