Food and bugfix

This commit is contained in:
2026-04-17 19:03:00 -04:00
parent 2f2f53bedb
commit d15a7f0aa9
4 changed files with 30 additions and 26 deletions

View File

@@ -1,8 +1,7 @@
class Cat:
def __init__(self, name, traits, food=0, money=25, inventory={}):
def __init__(self, name, traits, money=25, inventory={}):
self.name = name
self.traits = traits
self.food = food
self.money = money
self.inventory = inventory

View File

@@ -6,6 +6,7 @@ import data.save
import data.text
import os
import json
import traceback
class Game:
@@ -40,8 +41,8 @@ class Game:
options[0:0] = [ # AI came up with this, what the heck is [0:0]
"Save",
"Save and quit",
"Settings",
"Quit",
"Settings",
]
else:
print(
@@ -76,7 +77,7 @@ class Game:
print("Save complete.")
self.game_loop()
# TODO: Add shop, make food buyable and add money system
# TODO: Add money system
def game_loop(self):
ui.current_cat = self.cat
while True:
@@ -155,9 +156,9 @@ if __name__ == "__main__":
try:
game = Game()
game.run()
except Exception as e: # horrible coding right here
except: # horrible coding right here
print("Developer stuff incoming, if you can, tell me what this says:")
print(e)
traceback.print_exc()
print(
"Welp, seems that the game crashed, idk why. A common cause of this is pressing CTRL+C, which will cancel some UI stuff and just break the game. If you're on the desktop version, reopen it, if you're on the web version, reload, and don't use CTRL+C.\nOtherwise, great job! You found an issue in the game! If you can, please tell me."
)

View File

@@ -1,8 +1,15 @@
import data.cat
import systems.world
import systems.ui as ui
def handle_item(cat: data.cat.Cat, item):
def item_menu(cat: data.cat.Cat, item):
match item:
case "Food":
match ui.select("Please choose an option", [f"Feed your cat", "Back"]):
case "Feed your cat":
systems.world.feed(cat)
case "Back":
pass
case _:
pass
# TODO: MAKE THIS!

View File

@@ -99,7 +99,6 @@ def shop(cat: Cat):
else:
print("Cancelled.")
# TODO: idea, each item, when selected in house storage menu, call a item menu thing thats specific for each item
# TODO: make toy mouse that increases happyness (so also add emotions and sicknesses maybe) but has a 25% chance of getting lost under the couch and makes the cat tired possibly
case "Leave the shop":
print("Goodbye!")
@@ -146,27 +145,26 @@ def pet(cat: Cat):
print(f"You pet {cat.name} a lot. {cat.name} is very happy.")
def feed(cat):
# TODO: Make this use inventory["Food"] instead!
if cat.food <= 0:
def feed(cat: Cat):
if cat.inventory.get("Food", 0) <= 0:
print(f"You don't have any food. {cat.name} is sad.")
return
cat.food -= 1
cat.inventory["Food"] -= 1
print(f"You feed {cat.name}, {cat.name} is happy")
def storage(cat: Cat):
while True:
item = ui.select(
"Please choose an item",
[
ui.Choice(title=f"{name}: {amount}", value=name)
for name, amount in cat.inventory.items()
if amount > 0
]
+ ["Back"],
)
if item == "Back":
break
return
systems.items.item_menu(cat, item)
@@ -187,7 +185,6 @@ def house(cat: Cat):
print(
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes"
)
print(f"Food: {cat.food}")
case "Pet your cat":
pet(cat)
case "Feed your cat":