Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def heroes_dict(num):
- hero_dict = {}
- for i in range(num):
- hero_data = input().split(" ")
- hero_name = hero_data[0]
- hp = int(hero_data[1])
- mp = int(hero_data[2])
- hero_dict[hero_name] = [hp, mp]
- return hero_dict
- def cast_spell(current_hero, needed_mp, spell, current_hero_dict):
- if needed_mp <= current_hero_dict[current_hero][1]:
- current_hero_dict[current_hero][1] -= needed_mp
- return f"{current_hero} has successfully cast {spell} and now has {current_hero_dict[current_hero][1]} MP!"
- else:
- return f"{current_hero} does not have enough MP to cast {spell}!"
- def take_damage(hero, damage, attacker, heroes):
- if heroes[hero][0] > damage:
- heroes[hero][0] -= damage
- return f"{hero} was hit for {damage} HP by {attacker} and now has {heroes[hero][0]} HP left!"
- else:
- del heroes[hero]
- return f"{hero} has been killed by {attacker}!"
- def recharge(hero, recharge_mp, needed_mp, heroes):
- if needed_mp >= recharge_mp:
- heroes[hero][1] += recharge_mp
- return f"{hero} recharged for {recharge_mp} MP!"
- else:
- heroes[hero][1] += needed_mp
- return f"{hero} recharged for {needed_mp} MP!"
- def heal(hero, healed_hp, needed_hp, heroes):
- if needed_hp >= healed_hp:
- heroes[hero][0] += healed_hp
- return f"{hero} healed for {healed_hp} HP!"
- else:
- heroes[hero][0] += needed_hp
- return f"{hero} healed for {needed_hp} HP!"
- def get_info(heroes):
- for k, v in heroes.items():
- print(f"{k}")
- print(f" HP: {v[0]}")
- print(f" MP: {v[1]}")
- def main_func(heroes):
- command_data = input().split(" - ")
- while True:
- command = command_data[0]
- if command == "End":
- get_info(heroes)
- break
- if command == "CastSpell":
- hero = command_data[1]
- mp_need = int(command_data[2])
- spell_name = command_data[3]
- print(cast_spell(hero, mp_need, spell_name, heroes))
- elif command == "TakeDamage":
- hero = command_data[1]
- damage = int(command_data[2])
- attacker = command_data[3]
- print(take_damage(hero, damage, attacker, heroes))
- elif command == "Recharge":
- hero = command_data[1]
- recharge_mp = int(command_data[2])
- needed_mp = 200 - heroes[hero][1]
- print(recharge(hero, recharge_mp, needed_mp, heroes))
- elif command == "Heal":
- hero = command_data[1]
- healed_hp = int(command_data[2])
- needed_hp = 100 - heroes[hero][0]
- print(heal(hero, healed_hp, needed_hp, heroes))
- command_data = input().split(" - ")
- number = int(input())
- main_func(heroes_dict(number))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement