Advertisement
Rayk

MuOnline

Jul 13th, 2020
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. health = 100
  2. coins = 0
  3.  
  4. line = input().split('|')
  5. is_killed = False
  6. for i in range(len(line)):
  7.     tokens = line[i].split(' ')
  8.     command = tokens[0]
  9.     number = int(tokens[1])
  10.     if command == 'potion':
  11.         if health + number > 100:
  12.             number = 100 - health
  13.             health = 100
  14.         else:
  15.             health += number
  16.         print(f'You healed for {number} hp.')
  17.         print(f'Current health: {health} hp.')
  18.     elif command == 'chest':
  19.         coins += number
  20.         print(f'You found {number} bitcoins.')
  21.     else:
  22.         health -= number
  23.         if health > 0:
  24.             print(f'You slew {command}.')
  25.         else:
  26.             i += 1
  27.             print(f'You died! Killed by {command}.')
  28.             print(f'Best room: {i}')
  29.             is_killed = True
  30.             break
  31.  
  32. if not is_killed:
  33.     print("You've made it!")
  34.     print(f'Bitcoins: {coins}')
  35.     print(f'Health: {health}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement