diff --git a/data/cat.py b/data/cat.py index 6345cd6..7746e0b 100644 --- a/data/cat.py +++ b/data/cat.py @@ -11,6 +11,7 @@ class Cat: last_login=None, fullness=100, happiness=100, + sick=False, ): self.name = name self.traits = traits @@ -19,6 +20,7 @@ class Cat: self.inventory = inventory if inventory is not None else {} self.fullness = fullness # really hunger, but 100 hunger being defualt sounds like its 100% hungry so its fullness. self.happiness = happiness + self.sick = sick def apply_decay(self): # first neat function! yayyy! elapsed_hours = (time.time() - self.last_login) / 3600 @@ -26,6 +28,12 @@ class Cat: elapsed_hours = 0 self.fullness -= 5 * elapsed_hours self.happiness -= 5 * elapsed_hours + if self.fullness <= 0: + self.fullness = 0 + self.sick = True + print( + "Your cat didn't have enough food and got sick. There is medicine in the shop." + ) def to_dict(self): return vars(self) diff --git a/data/text.py b/data/text.py index 27b96ae..49e4d1d 100644 --- a/data/text.py +++ b/data/text.py @@ -33,6 +33,6 @@ CAT_PERSONALITIES = [ # TODO: start at different happiness levels based on pers CAT_EYE_COLORS = ["green", "yellow", "blue", "orange"] -SHOP_ITEMS = {"Food": 5} +SHOP_ITEMS = {"Food": 5, "Medicine": 15} BYPASS_TAMPER_CHECK_MESSAGE = "I truly understand that this is cheating and that it is ONLY for development and nothing else. I understand that it is mean to mess with my cat savefile and I apologize to my cat." diff --git a/systems/items.py b/systems/items.py index 5e94f4d..f56ae8b 100644 --- a/systems/items.py +++ b/systems/items.py @@ -11,5 +11,22 @@ def item_menu(cat: data.cat.Cat, item): systems.world.feed(cat) case "Back": pass + case "Medicine": + match ui.select( + "Please choose an option", [f"Give your cat the medicine", "Back"] + ): + case "Give your cat the medicine": + if cat.inventory.get("Medicine", False): + cat.sick = False + cat.fullness = 25.0 + cat.inventory["Medicine"] -= 1 + print( + f"{cat.name} eats the medicine. {cat.name} is feeling better! They still are hungry though." + ) + else: + print("You don't have any medicine!") + case "Back": + pass + case _: pass diff --git a/systems/world.py b/systems/world.py index 249d9c9..aa64fd2 100644 --- a/systems/world.py +++ b/systems/world.py @@ -129,6 +129,9 @@ def pet(cat: Cat): else: cat.happiness -= 5 print(f"\n{cat.name} ran away to protect your hands") + print( + f"You lost 5% happiness due to stressing your cat. Before petting, your cat was {original_happiness}% happy. You lost {original_happiness-cat.happiness}% happiness. Your cat is now {cat.happiness}% happy." + ) return if count == 0: print("You didn't pet your cat at all.") @@ -163,10 +166,6 @@ def pet(cat: Cat): if cat.happiness > 100: cat.happiness = 100 print("Your cat's happiness went above 100% and was capped back down to 100%.") - if cat.happiness < original_happiness: - print( - f"You lost 5% happiness due to stressing your cat. Before petting, your cat was {original_happiness}% happy. You lost {original_happiness-cat.happiness}% happiness. Your cat is now {cat.happiness}% happy." - ) else: print( f"Your cat is now {cat.happiness}% percent happy. Before petting, your cat was {original_happiness}% happy. You gained {cat.happiness-original_happiness}% happiness." @@ -174,6 +173,9 @@ def pet(cat: Cat): def feed(cat: Cat): + if cat.sick: + print(f"{cat.name} is too sick to eat, head over to the shop to buy medicine!") + return if cat.inventory.get("Food", 0) <= 0: print(f"You don't have any food. {cat.name} is sad.") return @@ -201,6 +203,8 @@ def storage(cat: Cat): def house(cat: Cat): print("Welcome to your house!") + if cat.sick: + print(f"{cat.name} is sick, go to the shop to get medicine!") while True: match ui.select( "Please choose an option", @@ -213,16 +217,29 @@ def house(cat: Cat): ], ): case "Check on your cat": - print( - f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes." - ) - print(f"Happiness: {round(cat.happiness,1)}%") - print(f"Fullness: {round(cat.fullness,1)}/100") - print(f"You have ${cat.money}.") + if not cat.sick: + print( + f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes." + ) + print(f"Happiness: {round(cat.happiness,1)}%") + print(f"Fullness: {round(cat.fullness,1)}/100") + print(f"You have ${cat.money}.") + else: + print(f"{cat.name} is still sick! Go to the shop to get medicine!") case "Pet your cat": - pet(cat) + if not cat.sick: + pet(cat) + else: + print( + f"{cat.name} is too sick for pets, go to the shop for medicine!" + ) case "Feed your cat": - feed(cat) + if not cat.sick: + feed(cat) + else: + print( + f"{cat.name} is too sick to eat, head over to the shop to buy medicine!" + ) case "Storage": storage(cat) case "Leave your house":