Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rooms = input().split("|")
- health = 100
- coins = 0
- dead = False
- for room in rooms:
- tokens = room.split(' ')
- item = tokens[0]
- if item == 'potion' and tokens[1].isdigit():
- value = int(tokens[1])
- if health == 100:
- print('You healed for 0 hp.\nCurrent health: 100 hp.')
- else:
- health += value
- if health < 100:
- print(f'You healed for {value} hp.\nCurrent health: {health} hp.')
- if health == 100:
- print(f'You healed for {value} hp.\nCurrent health: {health} hp.')
- if health > 100:
- print(f'You healed for {abs(health - 100 - value)} hp.\nCurrent health: 100 hp.')
- health = 100
- elif item == 'chest' and tokens[1].isdigit():
- coins_found = int(tokens[1])
- coins += coins_found
- print(f'You found {coins_found} coins.')
- elif item != 'potion' or item != 'chest':
- monster = tokens[0]
- health_lost = int(tokens[1])
- health -= health_lost
- if health > 0:
- print(f'You slayed {monster}.')
- else:
- print(f'You died! Killed by {monster}.\nBest room: {rooms.index(room) + 1}')
- dead = True
- break
- if not dead:
- print(f"You've made it!\nCoins: {coins}\nHealth: {health}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement