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."
def console(): while True: enterSpam = 0 stuff = raw_input("==> ") if stuff == "help": print "Available commands: help, aspect, bloodCalc, sweepCalc, playerData, and displayPlayerData" print "Enter help:<command> for information on \"command\"." elif stuff == "help:aspect": print "[u] Displays your Classpect (Class and Aspect)." elif stuff == "help:bloodCalc": print "Displays your blood color as if you were a troll." elif stuff == "help:sweepCalc": print "Converts Years to Alternian Sweeps and vice versa." elif stuff == "help:playerData": print "So far it does nothing." elif stuff == "help:displayPlayerData": print "It doesn't exist yet." elif stuff == "aspect": aspect.main(False) elif stuff == "bloodCalc": bloodCalc.main(False) elif stuff == "sweepCalc": sweepCalc.calc() elif stuff == "playerData": init.main(False) elif stuff == "displayPlayerData": dpd.main() else: print "'" + stuff + "' is not a valid command. Use \"help\" for information."
def console(): while True: enterSpam = 0 stuff = raw_input("==> ") if stuff == "help": print "Available commands: help, aspect, bloodCalc, sweepCalc, playerData, and displayPlayerData" print "Enter help:<command> for information on \"command\"." elif stuff == "help:aspect": print "[u] Displays your Classpect (Class and Aspect)." elif stuff == "aspect": unfin() elif stuff == "bloodCalc": bloodCalc.main(False) elif stuff == "sweepCalc": sweepCalc.calc() elif stuff == "playerData": unfin() elif stuff == "displayPlayerData": unfin() else: print "'" + stuff + "' is not a valid command. Use \"help\" for information."