Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- numbers = int(input())
- heroes_data = {}
- for _ in range(numbers):
- hero_name, hp, mp = input().split()
- hp = int(hp)
- mp = int(mp)
- heroes_data[hero_name] = [hp, mp]
- while True:
- command = input().split(" - ")
- if "End" == command[0]:
- break
- elif "CastSpell" == command[0]:
- hero, mp, spell = command[1:]
- if heroes_data[hero][1] >= int(mp):
- heroes_data[hero][1] -= int(mp)
- print(f"{hero} has successfully cast {spell} and now has {heroes_data[hero][1]} MP!")
- else:
- print(f"{hero} does not have enough MP to cast {spell}!")
- elif "TakeDamage" == command[0]:
- hero, damage, attacker = command[1:]
- if heroes_data[hero][0] - int(damage) > 0:
- heroes_data[hero][0] -= int(damage)
- print(f"{hero} was hit for {damage} HP by {attacker} and now has {heroes_data[hero][0]} HP left!")
- else:
- print(f"{hero} has been killed by {attacker}!")
- del heroes_data[hero]
- elif "Recharge" == command[0]:
- hero, amount = command[1:]
- if heroes_data[hero][1] + int(amount) >= 200:
- amount = 200 - heroes_data[hero][1]
- heroes_data[hero][1] += amount
- else:
- heroes_data[hero][1] += int(amount)
- print(f"{hero} recharged for {amount} MP!")
- elif "Heal" == command[0]:
- hero, amount = command[1:]
- if heroes_data[hero][0] + int(amount) >= 100:
- amount = 100 - heroes_data[hero][0]
- heroes_data[hero][0] += amount
- else:
- heroes_data[hero][0] += int(amount)
- print(f"{hero} healed for {amount} HP!")
- sorted_heroes = sorted(heroes_data.items(), key=lambda kvp: (-kvp[1][0], kvp[0]))
- for hero, data in sorted_heroes:
- print(f"""{hero}
- HP: {data[0]}
- MP: {data[1]}""")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement