/
init.py
38 lines (38 loc) · 1.44 KB
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import bloodCalc
import aspect
import json
import os.path
def main(init):
path = "./save_data.json"
if init == True:
if os.path.isfile(path):
with open("save_data.json", "r") as sf:
savefile = json.load(sf)
print "Welcome, " + savefile["handle"] + "."
else:
unsaved_data = {}
with open("save_data.json", "w") as f:
print "========= SBLUH FIRST TIME SETUP ========="
print "Please enter your handle in the form of:"
print "firstwordSecondword"
unsaved_data["handle"] = raw_input("==> ")
unsaved_data["classpect"] = aspect.main(True)
unsaved_data["bloodColor"] = bloodCalc.main(True)
print "[log] " + str(unsaved_data)
with open("save_data.json", "w") as saver:
json.dump(unsaved_data, saver)
print "Saving Complete."
else:
with open("save_data.json", "r+") as sf:
old_data = json.load(sf)
sf.truncate()
unsaved_data = {}
print "playerData Reset"
print
print "Enter your handle. (E.X. chumHandle)"
unsaved_data["handle"] = raw_input("==> ")
unsaved_data["classpect"] = aspect.main(True)
unsaved_data["bloodColor"] = bloodCalc.main(True)
with open("save_data.json", "r+") as newfile:
json.dump(unsaved_data, newfile)
print "Complete."