shop
This commit is contained in:
29
untitled/screens/shop.py
Normal file
29
untitled/screens/shop.py
Normal 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
|
||||
Reference in New Issue
Block a user