This commit is contained in:
2026-06-25 15:40:40 -04:00
parent fc81a46dd9
commit 988ddf1ebf
5 changed files with 51 additions and 3 deletions

View File

@@ -8,7 +8,9 @@ BASE_HAPPINESS_DECAY_PER_HOUR = 2
HUNGER_SADNESS_THRESHOLD = 30
HUNGER_SADNESS_PENALTY_PER_HOUR = 5
BASE_INVENTORY = {"food": 0, "medicine": 0, "catnip": 0}
ITEMS = {"food": 3, "medicine": 5, "catnip": 5}
BASE_INVENTORY = {item: 0 for item in ITEMS.keys()}
CAT_COLORS = [
"orange tabby",

View File

@@ -52,3 +52,11 @@ def feed(cat, amount=100):
def excite(cat, amount=100):
cat.happiness += amount
cat.happiness = _clamp(cat.happiness)
def buy(player, item, price):
if price > player.money:
return False
player.money -= price
player.inventory[item] += 1
return True

View File

@@ -1,4 +1,5 @@
from untitled import ui
from untitled.screens import shop
def options():
@@ -10,3 +11,9 @@ def options():
return "save"
case "Save and quit":
return "savequit"
def go_to(save):
match ui.select("Where do you want to go?", ["The shop", "Back"]):
case "The shop":
shop.shop(save)

View File

@@ -1,7 +1,7 @@
import time
from untitled import generation, model, persistence, rules, ui
from untitled.screens.common import options
from untitled.screens.common import options, go_to
def house(save: model.Save):
@@ -9,7 +9,7 @@ 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", "Menu"],
["Check on your cat", "Feed your cat", "Pet your cat", "Go to...", "Menu"],
):
case "Check on your cat":
rules.reconcile(save.cat, time.time())
@@ -24,6 +24,8 @@ def house(save: model.Save):
rules.reconcile(save.cat, time.time())
rules.excite(save.cat)
print(f"You pet {save.cat.name}, {save.cat.name} is now happy.")
case "Go to...":
go_to(save)
case "Menu":
result = options()
match result:

29
untitled/screens/shop.py Normal file
View File

@@ -0,0 +1,29 @@
from untitled import ui, content, model, rules
def shop(save: model.Save):
print("Welcome to the shop!")
while True:
match ui.select("What do you want to do?", ["Buy items", "Leave"]):
case "Buy items":
while True:
print(f"You have ${save.player.money}.")
item = ui.select(
"Please choose an item to buy:",
[
ui.Choice(f"{item.capitalize()}: ${price}", (item, price))
for item, price in content.ITEMS.items()
]
+ ["Back"],
)
if item == "Back":
break
if ui.confirm(
f"Are you sure you want to buy {item[0]} for ${item[1]}?"
):
if rules.buy(save.player, item[0], item[1]):
print("Done!")
else:
print("You don't have enough money!")
case "Leave":
break