Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- def find_best_room(rooms):
- max_value = -sys.maxsize
- for i in range(len(rooms)):
- room_tokens = rooms[i].split()
- if room_tokens[0] == 'chest':
- if int(room_tokens[1]) >= max_value:
- max_value = int(room_tokens[1])
- best_room_index = i
- return best_room_index
- initial_health = 100
- initial_bitcoins = 0
- is_dead = False
- rooms = input().split('|')
- health = initial_health
- bitcoins = initial_bitcoins
- best_room = None
- max_bitcoins = 0
- for i in range(len(rooms)):
- command = rooms[i]
- tokens = command.split()
- if tokens[0] == 'potion':
- health_points = int(tokens[1])
- if health + health_points > initial_health:
- health_points = initial_health - health
- health = initial_health
- else:
- health += health_points
- print(f'You healed for {health_points} hp.')
- print(f'Current health: {health} hp.')
- elif tokens[0] == 'chest':
- amount = int(tokens[1])
- print(f'You found {amount} bitcoins.')
- bitcoins += amount
- if bitcoins >= max_bitcoins:
- max_bitcoins = bitcoins
- best_room = find_best_room(rooms)
- else:
- monster = tokens[0]
- attack = int(tokens[1])
- health -= attack
- if health > 0:
- print(f'You slayed {monster}.')
- else:
- # best_room = find_best_rooms()
- print(f'You died! Killed by {monster}.')
- print(f'Best room: {best_room}')
- is_dead = True
- break
- if not is_dead:
- print(f"You've made it!")
- print(f"Bitcoins: {bitcoins}")
- print(f"Health: {health}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement