Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- dictionary_hp = {}
- dictionary_mp = {}
- for _ in range(n):
- line = input()
- line_split = line.split()
- hero_name = line_split[0]
- hp = int(line_split[1])
- mp = int(line_split[2])
- dictionary_hp[hero_name] = hp
- dictionary_mp[hero_name] = mp
- while True:
- data = input()
- if data == "End":
- break
- data_split = data.split(" - ")
- command = data_split[0]
- hero_name = data_split[1]
- if command == "CastSpell":
- mp_needed = int(data_split[2])
- spell_name = data_split[3]
- if dictionary_mp[hero_name] > mp_needed:
- dictionary_mp[hero_name] -= mp_needed
- print(f"{hero_name} has successfully cast {spell_name} and now has {dictionary_mp[hero_name]} MP!")
- else:
- print(f"{hero_name} does not have enough MP to cast {spell_name}!")
- elif command == "TakeDamage":
- damage = int(data_split[2])
- attacker = data_split[3]
- dictionary_hp[hero_name] -= damage
- if dictionary_hp[hero_name] > 0:
- print(f"{hero_name} was hit for {damage} HP by {attacker} and now has {dictionary_hp[hero_name]} HP left!")
- else:
- del dictionary_hp[hero_name]
- del dictionary_mp[hero_name]
- print(f"{hero_name} has been killed by {attacker}!")
- elif command == "Recharge":
- amount = int(data_split[2])
- diff = abs(200 - dictionary_mp[hero_name])
- dictionary_mp[hero_name] += amount
- if dictionary_mp[hero_name] > 200:
- print(f"{hero_name} recharged for {min(diff, amount)} MP!")
- dictionary_mp[hero_name] = 200
- else:
- print(f"{hero_name} recharged for {max(200 - dictionary_mp[hero_name], amount)} MP!")
- else:
- amount = int(data_split[2])
- diff = abs(100 - dictionary_hp[hero_name])
- dictionary_hp[hero_name] += amount
- if dictionary_hp[hero_name] > 100:
- print(f"{hero_name} healed for {min(diff, amount)} HP!")
- dictionary_hp[hero_name] = 100
- else:
- print(f"{hero_name} healed for {max(100 - dictionary_hp[hero_name], amount)} HP!")
- for hero_name in dictionary_hp.keys():
- print(hero_name)
- hp = dictionary_hp[hero_name]
- mp = dictionary_mp[hero_name]
- print(f" HP: {hp}")
- print(f" MP: {mp}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement