DiYane

MuOnline

Sep 18th, 2023
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.14 KB | None | 0 0
  1. max_health = 100
  2. is_dead = False
  3.  
  4. rooms = input().split('|')
  5.  
  6. health = max_health
  7. bitcoins = 0
  8. best_room = 0
  9.  
  10. for i in range(len(rooms)):
  11.     best_room += 1
  12.     command = rooms[i]
  13.     tokens = command.split()
  14.  
  15.     if tokens[0] == 'potion':
  16.         health_points = int(tokens[1])
  17.         if health + health_points > max_health:
  18.             health_points = max_health - health
  19.             health = max_health
  20.         else:
  21.             health += health_points
  22.         print(f'You healed for {health_points} hp.')
  23.         print(f'Current health: {health} hp.')
  24.  
  25.     elif tokens[0] == 'chest':
  26.         amount = int(tokens[1])
  27.         print(f'You found {amount} bitcoins.')
  28.         bitcoins += amount
  29.     else:
  30.         monster = tokens[0]
  31.         attack = int(tokens[1])
  32.         health -= attack
  33.         if health > 0:
  34.             print(f'You slayed {monster}.')
  35.         else:
  36.             print(f'You died! Killed by {monster}.')
  37.             print(f'Best room: {best_room}')
  38.             is_dead = True
  39.             break
  40.  
  41. if not is_dead:
  42.     print(f"You've made it!")
  43.     print(f"Bitcoins: {bitcoins}")
  44.     print(f"Health: {health}")
Tags: python
Add Comment
Please, Sign In to add comment