inventory and feed

This commit is contained in:
2026-06-25 16:32:40 -04:00
parent f61889195c
commit 188c1be7bf
4 changed files with 29 additions and 8 deletions

View File

@@ -15,6 +15,8 @@ BASE_INVENTORY = {item: 0 for item in ITEMS}
WORK_START_LETTERS = 2
WORK_EARN_PER_ROUND = 3
FOOD_RESTORE = 30
CAT_COLORS = [
"orange tabby",
"black",

View File

@@ -44,9 +44,12 @@ def reconcile(cat: model.Cat, now):
cat.last_updated = now
def feed(cat, amount=100):
cat.fullness += amount
cat.fullness = _clamp(cat.fullness)
def feed(player, cat, amount=content.FOOD_RESTORE):
if player.inventory["food"] <= 0:
return False
player.inventory["food"] -= 1
cat.fullness = _clamp(cat.fullness + amount)
return True
def excite(cat, amount=100):

View File

@@ -9,17 +9,32 @@ def house(save: model.Save):
while True:
match ui.select(
"What do you want to do?",
["Check on your cat", "Feed your cat", "Pet your cat", "Go to...", "Menu"],
[
"Check on your cat",
"View your inventory",
"Feed your cat",
"Pet your cat",
"Go to...",
"Menu",
],
):
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)}\nMoney: {save.player.money}"
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}\n\n{"\n".join(f'{item.capitalize()}: {amount}' for item,amount in save.player.inventory.items() if amount>0)}"
)
case "Feed your cat":
rules.reconcile(save.cat, time.time())
rules.feed(save.cat)
print(f"You feed {save.cat.name}, {save.cat.name} is now full.")
if rules.feed(save.player, save.cat):
print(
f"You feed {save.cat.name}, {save.cat.name} now is {save.cat.fullness}% full."
)
else:
print("You don't have any food!")
case "Pet your cat":
rules.reconcile(save.cat, time.time())
rules.excite(save.cat)