Fix hash debug menu+bypass hash in debug+new debug config system+shop+base for inventory system+what am i forgetting
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import os
|
||||
import questionary
|
||||
import sys
|
||||
import data.save
|
||||
import json
|
||||
from data.cat import Cat
|
||||
|
||||
current_cat: Cat | None = None
|
||||
|
||||
|
||||
def getch():
|
||||
@@ -21,16 +26,38 @@ def getch():
|
||||
termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
||||
|
||||
|
||||
def fix_hash():
|
||||
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)
|
||||
currentjson[f"saves/{current_cat.name}.kitten"] = data.save.hash_file(
|
||||
f"saves/{current_cat.name}.kitten"
|
||||
)
|
||||
print(
|
||||
f"Old hash: {currentjson.get(f"saves/{current_cat.name}.kitten")}. New hash: {currentjson[f"saves/{current_cat.name}.kitten"]}"
|
||||
)
|
||||
with open(hash_path, "w") as f:
|
||||
json.dump(currentjson, f)
|
||||
|
||||
|
||||
def debug_menu():
|
||||
print("hi")
|
||||
while True:
|
||||
match select(
|
||||
"choose ur way of breaking the game",
|
||||
["Breakpoint", "Back"],
|
||||
["Breakpoint", "Fix hash", "Back"],
|
||||
hide_debug=True,
|
||||
):
|
||||
case "Breakpoint":
|
||||
breakpoint()
|
||||
case "Fix hash":
|
||||
fix_hash()
|
||||
print(
|
||||
"If you see this message and theres no errors above I think it worked."
|
||||
)
|
||||
case "Back":
|
||||
break
|
||||
|
||||
@@ -51,10 +78,12 @@ STYLE = questionary.Style(
|
||||
]
|
||||
)
|
||||
|
||||
Choice = questionary.Choice
|
||||
|
||||
|
||||
def select(message, choices, hide_debug=False):
|
||||
choices = list(choices).copy().copy().copy().copy().copy().copy() # yay!
|
||||
if os.path.exists("ENABLE DEBUG") and hide_debug == False:
|
||||
if os.path.exists("debug.json") and hide_debug == False:
|
||||
if not "Debug Menu" in choices:
|
||||
choices.append("Debug Menu")
|
||||
choice = questionary.select(message, choices=choices, style=STYLE).ask()
|
||||
|
||||
Reference in New Issue
Block a user