🔥 monster and spell files no longer part

This commit is contained in:
Nikolaj Danger
2020-08-03 15:00:54 +02:00
parent 83a93145db
commit cd1eff01a0
4 changed files with 82 additions and 1 deletions

View File

@ -26,7 +26,7 @@ def monsterFunc(command):
# Opens "mensters.json"
data = json.load(open('resources/monsters.json', encoding = "utf8"))
for monster in data:
if str(command) == monster["name"]:
if "name" in monster and str(command) == monster["name"]:
logThis("Found it!")
# Looks at the information about the monster and returns that information

View File

@ -158,6 +158,29 @@ def makeFiles():
finally:
f.close()
# Creates monsters.json if it doesn't exist
try:
f = open("resources/monsters.json","r")
except:
logThis("monsters.json didn't exist. Making it now.")
with open("resources/lookupExamples.json") as f:
data = json.load(f)["monster"]
with open("resources/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")
except:
logThis("spells.json didn't exist. Making it now.")
with open("resources/lookupExamples.json") as f:
data = json.load(f)["spell"]
with open("resources/spells.json","w") as f:
json.dump(data,f,indent = 4)
finally:
f.close()
# Creates destinyPoints.txt if it doesn't exist
try: