import os import json import data.save import systems.ui # should cause circular import but doesn't, so not fixing it import data.text def fix_hash(current_cat): data_dir = data.save.get_data_dir() hash_path = os.path.join(data_dir, "dont hurt cats.json") os.makedirs(data_dir, exist_ok=True) if os.path.exists(hash_path): with open(hash_path, "r") as f: currentjson = json.load(f) old_hash = currentjson[f"saves/{current_cat.name}.kitten"] currentjson[f"saves/{current_cat.name}.kitten"] = data.save.hash_file( f"saves/{current_cat.name}.kitten" ) print( f"Old hash: {old_hash}. New hash: {currentjson[f"saves/{current_cat.name}.kitten"]}" ) with open(hash_path, "w") as f: json.dump(currentjson, f) def debug_menu(current_cat): print("hi") while True: match systems.ui.select( "choose ur way of breaking the game", ["Breakpoint", "Fix hash", "Debug settings", "Back"], hide_debug=True, ): case "Breakpoint": breakpoint() case "Fix hash": fix_hash(current_cat) print( "If you see this message and theres no errors above I think it worked." ) case "Debug settings": while True: with open("debug.json", "r") as f: config = json.load(f) enabled = config.get("bypass_tamper_check_enable", False) label = "Disable" if enabled else "Enable" match systems.ui.select( "choose a setting", [ systems.ui.Choice( title=f"{label} hash bypass", value="Toggle tamper check", ), "Configure auto savefile loading", "Back", ], hide_debug=True, ): case "Toggle tamper check": if ( config["bypass_tamper_check_message"] != data.text.BYPASS_TAMPER_CHECK_MESSAGE ): print( "If you already did this, you may have typed it wrong." ) print( "You need to set the message that you will not use this to cheat. Please type the following message EXACTLY." ) print(data.text.BYPASS_TAMPER_CHECK_MESSAGE) response = systems.ui.text("Type here:") config["bypass_tamper_check_message"] = response config["bypass_tamper_check_enable"] = not enabled with open("debug.json", "w") as f: json.dump(config, f) case "Configure auto savefile loading": while True: print( "Currently loads:", config.get("auto_load_savefile", "Unset"), ) match systems.ui.select( "Please choose an option", [ "Change file to load", "Unset auto savefile loading", "Back", ], hide_debug=True, ): case "Back": break case "Change file to load": print("Press enter to cancel") file = systems.ui.filepath( 'Please enter the path to your savefile (if it is in the normal "saves" folder, starts with saves/), eg: saves/example.kitten:', default="", ) if file: if os.path.exists(file): config["auto_load_savefile"] = file with open("debug.json", "w") as f: json.dump(config, f) else: print("This is an invalid path!") else: print("Cancelled.") case "Unset auto savefile loading": try: del config["auto_load_savefile"] except KeyError: print( "The autoload was already unset! Nothing was changed." ) else: with open("debug.json", "w") as f: json.dump(config, f) print("Done") case "Back": break case "Back": break