Some debug stuff

This commit is contained in:
2026-04-13 19:36:56 -04:00
parent 157bdba5fd
commit 3a90698193
3 changed files with 151 additions and 50 deletions

View File

@@ -3,9 +3,12 @@ import questionary
import sys
import data.save
import json
from data.cat import Cat
import data.cat
import data.text
import systems.debug
current_cat: Cat | None = None
current_cat: data.cat.Cat | None = None
def getch():
@@ -26,42 +29,6 @@ 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", "Fix hash", "Debug settings", "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
def clear():
os.system("cls" if os.name == "nt" else "clear")
@@ -89,7 +56,7 @@ def select(message, choices, hide_debug=False):
choice = questionary.select(message, choices=choices, style=STYLE).ask()
if choice != "Debug Menu":
return choice
debug_menu()
systems.debug.debug_menu(current_cat)
return select(message, choices)
@@ -99,3 +66,7 @@ def text(message, default=""):
def confirm(message, default=True):
return questionary.confirm(message, default=default, style=STYLE).ask()
def filepath(message, default=True):
return questionary.path(message, default=default, style=STYLE).ask()