Advertisement
Spocoman

10. Bread Factory

Jan 23rd, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. events = input().split('|')
  2. energy = 100
  3. coins = 100
  4. is_break = False
  5. for i in range(len(events)):
  6.     event = events[i].split('-')
  7.     if event[0] == 'rest':
  8.         if energy + int(event[1]) > 100:
  9.             event[1] = 100 - energy
  10.         energy += int(event[1])
  11.         print(f'You gained {event[1]} energy.\nCurrent energy: {energy}.')
  12.     elif event[0] == 'order':
  13.         if energy - 30 >= 0:
  14.             coins += int(event[1])
  15.             energy -= 30
  16.             print(f'You earned {int(event[1])} coins.')
  17.         else:
  18.             energy += 50
  19.             print('You had to rest!')
  20.     else:
  21.         if coins - int(event[1]) > 0:
  22.             coins -= int(event[1])
  23.             print(f'You bought {event[0]}.')
  24.         else:
  25.             print(f'Closed! Cannot afford {event[0]}.')
  26.             is_break = True
  27.             break
  28.  
  29. if is_break == False:
  30.     print(f'Day completed!\nCoins: {coins}\nEnergy: {energy}')
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement