Changes to stuff

This commit is contained in:
NikolajDanger
2020-03-31 19:39:44 +02:00
parent 436d0443dd
commit bdb011cfc5
9 changed files with 111 additions and 22 deletions

View File

@ -99,7 +99,17 @@ def lookUp(data : dict, key : str, cmd : str = ""):
else:
while cmd[0] == ' ':
cmd = cmd[1:]
if type(data[key]) != list:
if type(data[key]) is dict:
newKey = cmd.split(" ")[0]
cmd = cmd[len(newKey):]
while cmd[0] == " ":
cmd = cmd[1:]
if cmd == "":
break
data[key] = lookUp(data[key],newKey,cmd)
return data
elif type(data[key]) != list:
try:
cmd = type(data[key])(cmd)
data[key] = cmd
@ -162,13 +172,12 @@ def characterSheet(character : dict):
text8 = ""
if bool(character["Talents"]):
text5 = "**Talents**: "+",".join(list(character["Talents"]))+"\n\n"
text5 = "**Talents**: "+", ".join(list(character["Talents"]))+"\n\n"
if bool(character["Force-powers"]):
text6 = "**Force Powers**: "+",".join(list(character["Force-powers"]))+"\n\n"
text6 = "**Force Powers**: "+", ".join(list(character["Force-powers"]))+"\n\n"
if bool(character["Weapons"]):
text7 = "**Weapons**: "+",".join(list(character["Weapons"]))+"\n"+divider
text7 = "**Equipment**: "+", ".join(character["Equipment"])+"\n**Credits**: "+str(character["Credits"])+"\n**Weapons**: "+", ".join(list(character["Weapons"]))+"\n"+divider
if bool(character["Obligations"]):
text8 = "**Obligations**: "+",".join(list(character["Obligations"]))
@ -250,7 +259,7 @@ def charData(user : str,cmd : str):
except:
return "Can't do that"
if key == "Talents" or key == "Force-powers" or key == "Weapons":
if key == "Talents" or key == "Force-powers" or key == "Weapons" or key == "Obligations":
if cmd in data[user][key]:
del data[user][key][cmd]
with open("resources/swcharacters.json", "w") as f:
@ -298,7 +307,7 @@ def charData(user : str,cmd : str):
data[user][key] = beforeData+ int(cmd)
with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + user + "'s " + key
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except:
return "Can't add that"
elif type(data[user][key]) is list:
@ -306,7 +315,7 @@ def charData(user : str,cmd : str):
data[user][key].append(cmd)
with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Added " + cmd + " to " + user + "'s " + key
return "Added " + cmd + " to " + data[user]["Name"] + "'s " + key
except:
return "Can't add that"
else:
@ -325,7 +334,7 @@ def charData(user : str,cmd : str):
data[user][key] = beforeData - int(cmd)
with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Subtracted " + cmd + " from " + user + "'s " + key
return "Subtracted " + cmd + " from " + data[user]["Name"] + "'s " + key
except:
return "Can't remove that"
elif type(data[user][key]) is list:
@ -337,7 +346,7 @@ def charData(user : str,cmd : str):
return "Not in list"
with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "Removed " + cmd + " from " + user + "'s " + key
return "Removed " + cmd + " from " + data[user]["Name"] + "'s " + key
except:
return "Can't remove that"
else:
@ -412,7 +421,7 @@ def parseChar(user : str, cmd : str):
with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4)
return "", "Character for " + user + " deleted"
return "", replaceWithSpaces(charData(user,cmd))
return "", replaceWithSpaces(str(charData(user,cmd)))
def lightsaberChar(user : str):
with open("resources/swcharacters.json", "r") as f: