redo screen system

This commit is contained in:
2026-06-24 18:10:41 -04:00
parent f40565d861
commit b86b3af5a3
5 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
from untitled.screens.adoption import adoption as adoption
from untitled.screens.common import options as options
from untitled.screens.house import house as house

View File

@@ -0,0 +1,35 @@
from untitled import generation, model, rules, ui
def adoption():
print("Welcome to the shelter!")
while True:
auto_name = ""
choice = "Reroll"
while choice == "Reroll":
choices = generation.generate_cat_choices()
choice = ui.select(
"Please choose a cat to adopt:",
[ui.Choice(cat[0], cat[1]) for cat in choices] + ["Reroll"],
)
while True:
name = ui.text(
'Please choose a name for your cat or type "idk" to autofill a generated one:',
auto_name,
)
if name.lower() != "idk":
auto_name = ""
error = rules.validate_cat_name(name)
if not error:
break
print(error)
else:
auto_name = generation.generate_name()
if ui.confirm(
f"Do you want to adopt {name}, {generation.generate_trait_sentence(choice).lower()}?"
):
break
return model.Cat(name, choice)

View File

@@ -0,0 +1,12 @@
from untitled import ui
def options():
while True:
match ui.select("Please choose an option:", ["Save", "Save and quit", "Back"]):
case "Back":
return "back"
case "Save":
return "save"
case "Save and quit":
return "savequit"

23
untitled/screens/house.py Normal file
View File

@@ -0,0 +1,23 @@
from untitled import model, persistence, ui
from untitled.screens.common import options
def house(save: model.Save):
print("Welcome to your house!")
while True:
match ui.select("What do you want to do?", ["Check on your cat", "Menu"]):
case "Check on your cat":
print(save.cat.name)
case "Menu":
result = options()
match result:
case "save":
print("Saving...")
persistence.save(save)
print("Done")
case "savequit":
if ui.confirm("Are you sure you want to quit?"):
print("Saving...")
persistence.save(save)
print("Done")
break