30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
from untitled import content, model, rules, ui
|
|
|
|
|
|
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
|