Advertisement
simeonshopov

Dungeonest Dark

Jan 29th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. rooms = input().split("|")
  2. health = 100
  3. coins = 0
  4. dead = False
  5.  
  6. for room in rooms:
  7.     tokens = room.split(' ')
  8.     item = tokens[0]
  9.     if item == 'potion' and tokens[1].isdigit():
  10.         value = int(tokens[1])
  11.         if health == 100:
  12.             print('You healed for 0 hp.\nCurrent health: 100 hp.')
  13.         else:
  14.             health += value
  15.             if health < 100:
  16.                 print(f'You healed for {value} hp.\nCurrent health: {health} hp.')
  17.             if health == 100:
  18.                 print(f'You healed for {value} hp.\nCurrent health: {health} hp.')
  19.             if health > 100:
  20.                 print(f'You healed for {abs(health - 100 - value)} hp.\nCurrent health: 100 hp.')
  21.                 health = 100
  22.     elif item == 'chest' and tokens[1].isdigit():
  23.         coins_found = int(tokens[1])
  24.         coins += coins_found
  25.         print(f'You found {coins_found} coins.')
  26.     elif item != 'potion' or item != 'chest':
  27.         monster = tokens[0]
  28.         health_lost = int(tokens[1])
  29.         health -= health_lost
  30.         if health > 0:
  31.             print(f'You slayed {monster}.')
  32.         else:
  33.             print(f'You died! Killed by {monster}.\nBest room: {rooms.index(room) + 1}')
  34.             dead = True
  35.             break
  36.  
  37. if not dead:
  38.     print(f"You've made it!\nCoins: {coins}\nHealth: {health}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement