61 lines
2.4 KiB
Python
61 lines
2.4 KiB
Python
import time
|
|
|
|
from untitled import generation, model, persistence, rules, ui
|
|
from untitled.screens.common import go_to, 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",
|
|
"View your inventory",
|
|
"Feed your cat",
|
|
"Pet your cat",
|
|
"Go to...",
|
|
"Menu",
|
|
],
|
|
):
|
|
case "Check on your cat":
|
|
rules.reconcile(save.cat, time.time())
|
|
print(
|
|
f"{save.cat.name}, {generation.generate_trait_sentence(save.cat.traits).lower()}.\nFullness: {round(save.cat.fullness,1)}\nHappiness: {round(save.cat.happiness,1)}"
|
|
)
|
|
case "View your inventory":
|
|
print(f"Money: {save.player.money}")
|
|
if any(amount > 0 for amount in save.player.inventory.values()):
|
|
print(
|
|
f"\n\n{"\n".join(f'{item.capitalize()}: {amount}' for item,amount in save.player.inventory.items() if amount>0)}"
|
|
)
|
|
else:
|
|
print("You have no items!")
|
|
case "Feed your cat":
|
|
rules.reconcile(save.cat, time.time())
|
|
if rules.feed(save.player, save.cat):
|
|
print(
|
|
f"You feed {save.cat.name}, {save.cat.name} now is {round(save.cat.fullness,1)}% full."
|
|
)
|
|
else:
|
|
print("You don't have any food!")
|
|
case "Pet your cat":
|
|
rules.reconcile(save.cat, time.time())
|
|
rules.excite(save.cat)
|
|
print(f"You pet {save.cat.name}, {save.cat.name} is now happy.")
|
|
case "Go to...":
|
|
go_to(save)
|
|
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
|