Simple food and debug bugfix

This commit is contained in:
2026-04-12 17:21:56 -04:00
parent 7111c6220d
commit c92699888e
3 changed files with 17 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ class Cat:
def __init__(self, name, traits):
self.name = name
self.traits = traits
self.food = 3
def to_dict(self):
return vars(self)

View File

@@ -75,6 +75,7 @@ class Game:
if os.path.exists("ENABLE DEBUG"):
with open("ENABLE DEBUG", "r") as f:
file = f.read().strip()
if file:
self.cat = data.save.load(file)
self.game_loop()
print(f"{self.cat.name} says bye")

View File

@@ -107,18 +107,28 @@ def pet(cat: Cat):
print(f"You pet {cat.name} a lot. {cat.name} is very happy.")
def feed(cat):
if cat.food <= 0:
print(f"You don't have any food. {cat.name} is sad.")
cat.food -= 1
print(f"You feed {cat.name}, {cat.name} is happy")
def house(cat: Cat):
print("Welcome to your house!")
while True:
match ui.select(
"Please choose an option",
["Check on your cat", "Pet your cat", "Leave your house"],
["Check on your cat", "Pet your cat", "Feed your cat", "Leave your house"],
):
case "Check on your 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":
feed(cat)
case "Leave your house":
break