Advertisement
exDotaPro

bread_factory

Mar 10th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. string = input().split('|')
  2. coins = 100
  3. energy = 100
  4.  
  5. for command in string:
  6.     arg = command.split('-')
  7.     command = arg[0]
  8.     add_energy = int(arg[1])
  9.  
  10.     if command == 'rest':
  11.         if energy + add_energy <= 100:
  12.             energy += add_energy
  13.             print(f'You gained {add_energy} energy.')
  14.         else:
  15.             print('You gained 0 energy.')
  16.         print(f'Current energy: {energy}.')
  17.        
  18.     elif command == 'order':
  19.         if energy - 30 < 0:
  20.             energy += 50
  21.             print('You had to rest!')
  22.         else:
  23.             energy -= 30
  24.             new_coins = add_energy
  25.             coins += new_coins
  26.             print(f'You earned {new_coins} coins.')
  27.            
  28.     else:
  29.         if coins - add_energy > 0:
  30.             coins -= add_energy
  31.             print(f'You bought {command}.')
  32.         else:
  33.             print(f'Closed! Cannot afford {command}.')
  34.             exit(0)
  35.  
  36. print('Day completed!')
  37. print(f'Coins: {coins}')
  38. print(f'Energy: {energy}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement