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