Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- count = int(input())
- heroes = {}
- for x in range(count):
- hero = input()
- name, hp, mp = hero.split()[0], int(hero.split()[1]), int(hero.split()[2])
- if hp > 100:
- hp = 100
- if mp > 200:
- mp = 200
- heroes[name] = [hp, mp]
- commands = input()
- while commands != 'End':
- cmd = commands.split(' - ')[0]
- if cmd == 'CastSpell':
- name, mp_needed, spell_name = commands.split(" - ")[1:]
- if heroes[name][1] >= int(mp_needed):
- heroes[name][1] -= int(mp_needed)
- print(f"{name} has successfully cast {spell_name} and now has {heroes[name][1]} MP!")
- else:
- print(f"{name} does not have enough MP to cast {spell_name}!")
- elif cmd == 'TakeDamage':
- name, damage, attacker = commands.split(' - ')[1:]
- heroes[name][0] -= int(damage)
- if heroes[name][0] > 0:
- print(f"{name} was hit for {damage} HP by {attacker} and now has {heroes[name][0]} HP left!")
- else:
- heroes.pop(name)
- print(f"{name} has been killed by {attacker}!")
- elif cmd == 'Recharge':
- name, amount = commands.split(" - ")[1], int(commands.split(" - ")[2])
- heroes[name][1] += int(amount)
- if heroes[name][1] > 200:
- diff = heroes[name][1] - 200
- heroes[name][1] = 200
- else:
- diff = 0
- print(f'{name} recharged for {int(amount)-diff} MP!')
- elif cmd == 'Heal':
- name, amount = commands.split(" - ")[1:]
- heroes[name][0] += int(amount)
- if heroes[name][0] > 100:
- diff = heroes[name][0] - 100
- heroes[name][0] = 100
- else:
- diff = 0
- print(f'{name} healed for {int(amount)-diff} HP!')
- commands = input()
- for name, stats in sorted(sorted(heroes.items(), key=lambda y: y[0]), key=lambda y: y[1][0], reverse=True):
- print(f'{name}')
- print(f' HP: {stats[0]}')
- print(f' MP: {stats[1]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement