Made the whole thing work
This commit is contained in:
@ -2,7 +2,7 @@ import json
|
||||
import string
|
||||
|
||||
def getName(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
@ -81,7 +81,7 @@ def characterSheet(character : dict):
|
||||
return name, text1+"\n\n"+text2+divider+text3
|
||||
|
||||
def charData(user : str,cmd : str):
|
||||
with open("characters.json", "r") as f:
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
key = string.capwords(cmd.split(" ")[0])
|
||||
@ -107,7 +107,7 @@ def charData(user : str,cmd : str):
|
||||
|
||||
if type(lookUpResult) is dict:
|
||||
data[user][key] = lookUpResult
|
||||
with open("characters.json", "w") as f:
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key
|
||||
else:
|
||||
@ -133,7 +133,7 @@ def charData(user : str,cmd : str):
|
||||
return "Can't add that"
|
||||
else:
|
||||
data[user][key] = cmd
|
||||
with open("characters.json", "w") as f:
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
|
||||
else:
|
||||
@ -142,7 +142,7 @@ def charData(user : str,cmd : str):
|
||||
return "You don't have a character. You can make one with !swchar"
|
||||
|
||||
def parseChar(user : str, cmd : str):
|
||||
with open("characters.json", "r") as f:
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if cmd == " ":
|
||||
@ -157,25 +157,25 @@ def parseChar(user : str, cmd : str):
|
||||
if user in data:
|
||||
return characterSheet(data[user])
|
||||
else:
|
||||
with open("templates.json", "r") as f:
|
||||
with open("funcs/swfuncs/templates.json", "r") as f:
|
||||
templates = json.load(f)
|
||||
newChar = templates["Character"]
|
||||
data[user] = newChar
|
||||
with open("characters.json", "w") as f:
|
||||
with open("funcs/swfuncs/characters.json", "w") as f:
|
||||
json.dump(data,f,indent = 4)
|
||||
return "", "Character for " + user + " created"
|
||||
else:
|
||||
return "", charData(user,cmd)
|
||||
|
||||
def lightsaberChar(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
if user in data:
|
||||
return data[user]["Lightsaber Characteristic"]
|
||||
|
||||
def userHasChar(user : str):
|
||||
with open("characters.json", "r") as f:
|
||||
with open("funcs/swfuncs/characters.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
return user in data
|
||||
|
Reference in New Issue
Block a user