inventory and feed
This commit is contained in:
@@ -62,10 +62,11 @@ def test_decay_and_replenish():
|
|||||||
last_updated=0,
|
last_updated=0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
cat.player.inventory["food"] = 1
|
||||||
rules.reconcile(cat.cat, 3600 * 2)
|
rules.reconcile(cat.cat, 3600 * 2)
|
||||||
assert cat.cat.happiness < 98
|
assert cat.cat.happiness < 98
|
||||||
assert cat.cat.fullness < 98
|
assert cat.cat.fullness < 98
|
||||||
rules.feed(cat.cat)
|
rules.feed(cat.player, cat.cat)
|
||||||
assert cat.cat.fullness == pytest.approx(100)
|
assert cat.cat.fullness == pytest.approx(100)
|
||||||
rules.reconcile(cat.cat, 7200 + 20 * 3600)
|
rules.reconcile(cat.cat, 7200 + 20 * 3600)
|
||||||
assert cat.cat.happiness < 96 - (content.BASE_HAPPINESS_DECAY_PER_HOUR * 20)
|
assert cat.cat.happiness < 96 - (content.BASE_HAPPINESS_DECAY_PER_HOUR * 20)
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ BASE_INVENTORY = {item: 0 for item in ITEMS}
|
|||||||
WORK_START_LETTERS = 2
|
WORK_START_LETTERS = 2
|
||||||
WORK_EARN_PER_ROUND = 3
|
WORK_EARN_PER_ROUND = 3
|
||||||
|
|
||||||
|
FOOD_RESTORE = 30
|
||||||
|
|
||||||
CAT_COLORS = [
|
CAT_COLORS = [
|
||||||
"orange tabby",
|
"orange tabby",
|
||||||
"black",
|
"black",
|
||||||
|
|||||||
@@ -44,9 +44,12 @@ def reconcile(cat: model.Cat, now):
|
|||||||
cat.last_updated = now
|
cat.last_updated = now
|
||||||
|
|
||||||
|
|
||||||
def feed(cat, amount=100):
|
def feed(player, cat, amount=content.FOOD_RESTORE):
|
||||||
cat.fullness += amount
|
if player.inventory["food"] <= 0:
|
||||||
cat.fullness = _clamp(cat.fullness)
|
return False
|
||||||
|
player.inventory["food"] -= 1
|
||||||
|
cat.fullness = _clamp(cat.fullness + amount)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def excite(cat, amount=100):
|
def excite(cat, amount=100):
|
||||||
|
|||||||
@@ -9,17 +9,32 @@ def house(save: model.Save):
|
|||||||
while True:
|
while True:
|
||||||
match ui.select(
|
match ui.select(
|
||||||
"What do you want to do?",
|
"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":
|
case "Check on your cat":
|
||||||
rules.reconcile(save.cat, time.time())
|
rules.reconcile(save.cat, time.time())
|
||||||
print(
|
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":
|
case "Feed your cat":
|
||||||
rules.reconcile(save.cat, time.time())
|
rules.reconcile(save.cat, time.time())
|
||||||
rules.feed(save.cat)
|
if rules.feed(save.player, save.cat):
|
||||||
print(f"You feed {save.cat.name}, {save.cat.name} is now full.")
|
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":
|
case "Pet your cat":
|
||||||
rules.reconcile(save.cat, time.time())
|
rules.reconcile(save.cat, time.time())
|
||||||
rules.excite(save.cat)
|
rules.excite(save.cat)
|
||||||
|
|||||||
Reference in New Issue
Block a user