This commit is contained in:
2026-04-20 19:32:50 -04:00
parent 080d23d7b6
commit 359a331ec4
4 changed files with 55 additions and 13 deletions

View File

@@ -11,6 +11,7 @@ class Cat:
last_login=None, last_login=None,
fullness=100, fullness=100,
happiness=100, happiness=100,
sick=False,
): ):
self.name = name self.name = name
self.traits = traits self.traits = traits
@@ -19,6 +20,7 @@ class Cat:
self.inventory = inventory if inventory is not None else {} 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.fullness = fullness # really hunger, but 100 hunger being defualt sounds like its 100% hungry so its fullness.
self.happiness = happiness self.happiness = happiness
self.sick = sick
def apply_decay(self): # first neat function! yayyy! def apply_decay(self): # first neat function! yayyy!
elapsed_hours = (time.time() - self.last_login) / 3600 elapsed_hours = (time.time() - self.last_login) / 3600
@@ -26,6 +28,12 @@ class Cat:
elapsed_hours = 0 elapsed_hours = 0
self.fullness -= 5 * elapsed_hours self.fullness -= 5 * elapsed_hours
self.happiness -= 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): def to_dict(self):
return vars(self) return vars(self)

View File

@@ -33,6 +33,6 @@ CAT_PERSONALITIES = [ # TODO: start at different happiness levels based on pers
CAT_EYE_COLORS = ["green", "yellow", "blue", "orange"] 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." 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."

View File

@@ -11,5 +11,22 @@ def item_menu(cat: data.cat.Cat, item):
systems.world.feed(cat) systems.world.feed(cat)
case "Back": case "Back":
pass 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 _: case _:
pass pass

View File

@@ -129,6 +129,9 @@ def pet(cat: Cat):
else: else:
cat.happiness -= 5 cat.happiness -= 5
print(f"\n{cat.name} ran away to protect your hands") 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 return
if count == 0: if count == 0:
print("You didn't pet your cat at all.") print("You didn't pet your cat at all.")
@@ -163,10 +166,6 @@ def pet(cat: Cat):
if cat.happiness > 100: if cat.happiness > 100:
cat.happiness = 100 cat.happiness = 100
print("Your cat's happiness went above 100% and was capped back down to 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: else:
print( 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." 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): 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: if cat.inventory.get("Food", 0) <= 0:
print(f"You don't have any food. {cat.name} is sad.") print(f"You don't have any food. {cat.name} is sad.")
return return
@@ -201,6 +203,8 @@ def storage(cat: Cat):
def house(cat: Cat): def house(cat: Cat):
print("Welcome to your house!") print("Welcome to your house!")
if cat.sick:
print(f"{cat.name} is sick, go to the shop to get medicine!")
while True: while True:
match ui.select( match ui.select(
"Please choose an option", "Please choose an option",
@@ -213,16 +217,29 @@ def house(cat: Cat):
], ],
): ):
case "Check on your cat": case "Check on your cat":
print( if not cat.sick:
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes." 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"Happiness: {round(cat.happiness,1)}%")
print(f"You have ${cat.money}.") 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": 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": 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": case "Storage":
storage(cat) storage(cat)
case "Leave your house": case "Leave your house":