Advertisement
George_Ivanov05

0.2

Jun 26th, 2021
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. initial_health = 100
  2. initial_bitcoins = 0
  3.  
  4. dungeons_rooms = input().split("|")
  5. best_room = 0
  6.  
  7. is_alive = True
  8.  
  9. for room in dungeons_rooms:
  10.     room_info = room.split(" ")
  11.     command = room_info[0]
  12.     number = int(room_info[1])
  13.     best_room += 1
  14.     if command == "potion":
  15.         health_gained = number
  16.         if initial_health + number > 100:
  17.             health_gained = 100 - initial_health
  18.         initial_health += health_gained
  19.         print(f"You healed for {health_gained} hp.")
  20.         print(f"Current health: {initial_health} hp.")
  21.     elif command == "chest":
  22.         initial_bitcoins += number
  23.         print(f"You have found {number} bitcoins.")
  24.     else:
  25.         monster = command
  26.         damage = number
  27.         if initial_health - damage > 0:
  28.             initial_health -= damage
  29.             print(f"You slayed {monster}")
  30.         else:
  31.             print(f"You died! Killed by {monster}")
  32.             print(f"Best room: {room}")
  33.             is_alive = False
  34.             break
  35. if is_alive:
  36.     print("You have made it!")
  37.     print(f"Bitcoins: {initial_bitcoins}")
  38.     print(f"Health: {initial_health}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement