Advertisement
Guest User

Untitled

a guest
Jan 17th, 2021
381
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MAX_ENERGY = 100
  2. energy = 100
  3. coins = 100
  4. events = input().split('|')
  5.  
  6. for event in events:
  7.     type_of_event, value = event.split('-')
  8.     value = int(value)
  9.     if type_of_event == 'rest':
  10.         gained = min(value, MAX_ENERGY - energy)
  11.         energy += gained
  12.         print(f'You gained {gained} energy.')
  13.         print(f'Current energy: {energy}.')
  14.  
  15.     elif type_of_event == 'order':
  16.         if energy >= 30:
  17.             energy -= 30
  18.             coins += value
  19.             print(f'You earned {value} coins.')
  20.         else:
  21.             energy += 50
  22.             print(f'You had to rest!')
  23.  
  24.     else:
  25.         coins -= value
  26.         if coins > 0:
  27.             print(f'You bought {type_of_event}.')
  28.         else:
  29.             print(f'Closed! Cannot afford {type_of_event}.')
  30.             break
  31.  
  32. if coins > 0:
  33.     print('Day completed!')
  34.     print(f'Coins: {coins}')
  35.     print(f'Energy: {energy}')
  36.  
Advertisement
RAW Paste Data Copied
Advertisement