Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- max_health_points = 100
- max_mana_points = 200
- n = int(input())
- heroes_party = {}
- for _ in range(n):
- hero = input()
- name = hero.split()[0]
- hp = int(hero.split()[1])
- mp = int(hero.split()[2])
- if hp <= max_health_points and mp <= max_mana_points:
- if name not in heroes_party:
- heroes_party[name] = {'health_points': 0, 'mana_points': 0}
- heroes_party[name]['health_points'] = hp
- heroes_party[name]['mana_points'] = mp
- commands = input()
- while not commands == "End":
- command = commands.split(" - ")[0]
- hero_name = commands.split(" - ")[1]
- if command == "CastSpell":
- needed_mana_points = int(commands.split(" - ")[2])
- spell_name = commands.split(" - ")[3]
- if needed_mana_points <= heroes_party[hero_name]['mana_points']:
- heroes_party[hero_name]['mana_points'] -= needed_mana_points
- print(f"{hero_name}"
- f" has successfully cast {spell_name}"
- f" and now has {heroes_party[hero_name]['mana_points']} MP!")
- else:
- print(f"{hero_name} does not have enough MP to cast {spell_name}!")
- elif command == "TakeDamage":
- damage = int(commands.split(" - ")[2])
- attacker = commands.split(" - ")[3]
- heroes_party[hero_name]['health_points'] -= damage
- if heroes_party[hero_name]['health_points'] > 0:
- print(f"{hero_name} was hit for {damage}"
- f" HP by {attacker} and now has "
- f"{heroes_party[hero_name]['health_points']} HP left!")
- else:
- del heroes_party[hero_name]
- print(f"{hero_name} has been killed by {attacker}!")
- elif command == "Recharge":
- amount = int(commands.split(" - ")[2])
- heroes_party[hero_name]['mana_points'] += amount
- if heroes_party[hero_name]['mana_points'] > max_mana_points:
- recharged_for = heroes_party[hero_name]['mana_points'] - max_mana_points
- heroes_party[hero_name]['mana_points'] -= recharged_for
- print(f"{hero_name} recharged for {recharged_for} MP!")
- else:
- print(f"{hero_name} recharged for {amount} MP!")
- elif command == "Heal":
- amount = int(commands.split(" - ")[2])
- health_before_the_heal = heroes_party[hero_name]['health_points']
- heroes_party[hero_name]['health_points'] += amount
- if heroes_party[hero_name]['health_points'] > max_health_points:
- healed_for = (max_health_points - health_before_the_heal)
- heroes_party[hero_name]['health_points'] = (health_before_the_heal + healed_for)
- print(f"{hero_name} healed for {healed_for} HP!")
- else:
- print(f"{hero_name} healed for {amount} HP!")
- commands = input()
- survived_heroes = sorted(heroes_party.items(), key=lambda tkvp: (-tkvp[1]['health_points'], tkvp[0]))
- for player, data in survived_heroes:
- print(f"{player}")
- print(f" HP: {data['health_points']}")
- print(f" MP: {data['mana_points']}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement