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

@@ -16,6 +16,8 @@ WORK_START_LETTERS = 2
WORK_EARN_PER_ROUND = 3
FOOD_RESTORE = 30
CATNIP_RESTORE = 20
MEDICINE_RESTORE = 20
CAT_COLORS = [
"orange tabby",

View File

@@ -41,6 +41,11 @@ def reconcile(cat: model.Cat, now):
cat.happiness -= content.HUNGER_SADNESS_PENALTY_PER_HOUR * elapsed_hours
cat.happiness = _clamp(cat.happiness)
if cat.happiness == 0:
cat.depressed = True
if cat.fullness == 0:
cat.sick = True
cat.last_updated = now
@@ -52,6 +57,24 @@ def feed(player, cat, amount=content.FOOD_RESTORE):
return True
def cure_sick(save, restore=content.MEDICINE_RESTORE):
if save.player.inventory["medicine"] <= 0:
return False
save.cat.fullness = restore
save.cat.sick = False
save.player.inventory["medicine"] -= 1
return True
def cure_depressed(save, restore=content.CATNIP_RESTORE):
if save.player.inventory["catnip"] <= 0:
return False
save.cat.happiness = restore
save.cat.depressed = False
save.player.inventory["catnip"] -= 1
return True
def excite(cat, amount=100):
cat.happiness += amount
cat.happiness = _clamp(cat.happiness)

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,18 +25,22 @@ def house(save: model.Save):
):
case "Check on your cat":
rules.reconcile(save.cat, time.time())
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":
if not save.cat.sick:
rules.reconcile(save.cat, time.time())
if rules.feed(save.player, save.cat):
print(
@@ -40,9 +48,14 @@ def house(save: model.Save):
)
else:
print("You don't have any food!")
else:
print(f"{save.cat.name} is sick!")
case "Pet your 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