Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- energy = 100
- coins = 100
- events = input().split("|")
- fail = 0
- energy1 = 0
- for idx in events:
- command = idx.split("-")
- action = command[0]
- value = int(command[1])
- if action == "rest":
- energy1 = energy
- energy += value
- if energy > 100 and energy1 < 100:
- print(f"You gained {energy - 100} energy.\n"
- f"Current energy: 100.")
- energy = 100
- elif energy1 == 100:
- print("You gained 0 energy.\n"
- "Current energy: 100.")
- energy = 100
- else:
- print(f"You gained {value} energy.\n"
- f"Current energy: {energy}.")
- elif action == "order":
- if energy <= 30:
- energy += 50
- print("You had to rest!")
- fail += 1
- continue
- else:
- coins += value
- print(f"You earned {value} coins.")
- energy -= 30
- else:
- if coins >= value:
- coins -= value
- print(f"You bought {action}.")
- else:
- fail += 1
- print(f"Closed! Cannot afford {action}.")
- break
- if fail == 0:
- print(f"Day completed!\n"
- f"Coins: {coins}\n"
- f"Energy: {energy}")
Advertisement
Add Comment
Please, Sign In to add comment