From 6b44022022122313fb9845e8233a9790da30bf24 Mon Sep 17 00:00:00 2001 From: Toasterkitten Date: Fri, 26 Jun 2026 19:30:30 -0400 Subject: [PATCH] depression+sick+inventory+pain --- untitled/content.py | 2 + untitled/rules.py | 23 +++++++++++ untitled/screens/house.py | 43 ++++++++++++------- untitled/screens/inventory.py | 77 +++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 untitled/screens/inventory.py diff --git a/untitled/content.py b/untitled/content.py index b660e6c..3baa0e7 100644 --- a/untitled/content.py +++ b/untitled/content.py @@ -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", diff --git a/untitled/rules.py b/untitled/rules.py index 5adeecf..ccf4982 100644 --- a/untitled/rules.py +++ b/untitled/rules.py @@ -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) diff --git a/untitled/screens/house.py b/untitled/screens/house.py index 63e1bb7..dbeb1fb 100644 --- a/untitled/screens/house.py +++ b/untitled/screens/house.py @@ -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": diff --git a/untitled/screens/inventory.py b/untitled/screens/inventory.py new file mode 100644 index 0000000..59c1214 --- /dev/null +++ b/untitled/screens/inventory.py @@ -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