GeorgiLukanov87

bakery

Jun 1st, 2022 (edited)
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. events = input().split('|')
  2. energy = 100
  3. coins = 100
  4. closed = False
  5. for event in events:
  6.     action, numbers = event.split('-')
  7.     numbers = int(numbers)
  8.     if action == 'rest':
  9.         temp = energy + numbers
  10.         if temp >= 100:
  11.             print(f'You gained {100 - energy} energy.')
  12.         else:
  13.             print(f'You gained {numbers} energy.')
  14.         energy += numbers
  15.            
  16.         if energy > 100:
  17.             energy = 100
  18.  
  19.         print(f'Current energy: {energy}.')
  20.  
  21.     elif action == 'order':
  22.         if energy < 30:
  23.             energy += 50
  24.             print(f"You had to rest!")
  25.             continue
  26.         coins += numbers
  27.         energy -= 30
  28.         print(f"You earned {numbers} coins.")
  29.  
  30.     else:
  31.         if coins >= numbers:
  32.             coins -= numbers
  33.             print(f"You bought {action}.")
  34.         else:
  35.             print(f"Closed! Cannot afford {action}.")
  36.             closed = True
  37.             break
  38.  
  39. if not closed:
  40.     print(f"Day completed!")
  41.     print(f"Coins: {coins}")
  42.     print(f"Energy: {energy}")
Add Comment
Please, Sign In to add comment