depression+sick+inventory+pain

This commit is contained in:
2026-06-26 19:30:30 -04:00
parent 7e85543c21
commit 6b44022022
4 changed files with 130 additions and 15 deletions

View File

@@ -1,12 +1,16 @@
import time
from untitled import generation, model, persistence, rules, ui
from untitled.screens import pet
from untitled.screens import inventory, pet
from untitled.screens.common import go_to, options
def house(save: model.Save):
print("Welcome to your house!")
if save.cat.sick or save.cat.depressed:
print(
f"Your cat is {"sick" if save.cat.sick else ""}{" and " if save.cat.sick and save.cat.depressed else ""}{"depressed" if save.cat.depressed else ""}. "
)
while True:
match ui.select(
"What do you want to do?",
@@ -21,28 +25,37 @@ def house(save: model.Save):
):
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)}"
)
if save.cat.sick or save.cat.depressed:
print(
f"{save.cat.name}: a {"sick" if save.cat.sick else ""}{" and " if save.cat.sick and save.cat.depressed else ""}{"depressed" if save.cat.depressed else ""} cat."
)
else:
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)}"
)
inventory.inventory(save)
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} is now {round(save.cat.fullness,1)}% full."
)
if not save.cat.sick:
rules.reconcile(save.cat, time.time())
if rules.feed(save.player, save.cat):
print(
f"You feed {save.cat.name}, {save.cat.name} is now {round(save.cat.fullness,1)}% full."
)
else:
print("You don't have any food!")
else:
print("You don't have any food!")
print(f"{save.cat.name} is sick!")
case "Pet your cat":
rules.reconcile(save.cat, time.time())
pet.pet(save.cat)
if not save.cat.depressed:
rules.reconcile(save.cat, time.time())
pet.pet(save.cat)
else:
print(f"{save.cat.name} is depressed!")
case "Go to...":
go_to(save)
case "Menu":

View File

@@ -0,0 +1,77 @@
import time
from untitled import rules, ui
def use_medicine(save):
match ui.select(
"What do you want to do with the medicine?",
[f"Give to {save.cat.name}", "Back"],
):
case "Back":
return True # keep in inventory menu
case give if give == f"Give to {save.cat.name}":
if save.cat.sick:
rules.reconcile(save.cat, time.time())
if save.player.inventory["medicine"] > 0:
rules.cure_sick(save)
print(
f"You give {save.cat.name} the medicine. They start to feel better. You should probably still feed them."
)
else:
print(
"You don't have any medicine! (what?) (you shouldn't see this)"
)
return False
else:
print(f"{save.cat.name} isn't sick!")
return False
return False
def use_catnip(save):
match ui.select(
"What do you want to do with the catnip?",
[f"Give to {save.cat.name}", "Back"],
):
case "Back":
return True # keep in inventory menu
case give if give == f"Give to {save.cat.name}":
if save.cat.depressed:
rules.reconcile(save.cat, time.time())
if save.player.inventory["catnip"] > 0:
rules.cure_depressed(save)
print(
f"You give {save.cat.name} the catnip. They begin to feel happier. You should probably still pet them."
)
else:
print("You don't have any catnip! (what?) (you shouldn't see this)")
return False
else:
print(f"{save.cat.name} isn't depressed!")
return False
return False
def inventory(save):
while True:
item = ui.select(
"Please choose an item:",
[
item.capitalize()
for item in save.player.inventory
if save.player.inventory[item] > 0 and item != "food" # in main program
]
+ ["Cancel"],
)
if item == "Cancel":
return
match item:
case "Medicine":
stay = use_medicine(save)
case "Catnip":
stay = use_catnip(save)
case _:
stay = False
if not stay:
break