Advertisement
KNenov96

Untitled

Oct 25th, 2022 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.47 KB | None | 0 0
  1. number_of_heroes = int(input())
  2.  
  3.  
  4. def creating_party(party_range):
  5.     heroes_in_party = {}
  6.     for hero in range(party_range):
  7.         current_hero = input().split()
  8.         name_of_hero = current_hero[0]
  9.         hp_current_hero = int(current_hero[1])
  10.         mp_current_hero = int(current_hero[2])
  11.         heroes_in_party[name_of_hero] = [hp_current_hero, mp_current_hero]
  12.     return heroes_in_party
  13.  
  14.  
  15. our_hero_party = creating_party(number_of_heroes)
  16.  
  17.  
  18. def command_performing(type_commands: list):
  19.     global our_hero_party
  20.     current_perform = type_commands[0]
  21.     hero_name = type_commands[1]
  22.     if current_perform == "CastSpell":
  23.         mp_needed = int(type_commands[2])
  24.         spell_name = type_commands[3]
  25.         if our_hero_party[hero_name][1] >= mp_needed:
  26.             our_hero_party[hero_name][1] -= mp_needed
  27.             return f"{hero_name} has successfully cast {spell_name} and now has {our_hero_party[hero_name][1]} MP!"
  28.         else:
  29.             return f"{hero_name} does not have enough MP to cast {spell_name}!"
  30.     elif current_perform == "TakeDamage":
  31.         damage = int(type_commands[2])
  32.         attacker = type_commands[3]
  33.         our_hero_party[hero_name][0] -= damage
  34.         if our_hero_party[hero_name][0] > 0:
  35.             return f"{hero_name} was hit for {damage} HP by {attacker} and now has {our_hero_party[hero_name][0]} HP left!"
  36.         else:
  37.             del (our_hero_party[hero_name])
  38.             return f"{hero_name} has been killed by {attacker}!"
  39.     elif current_perform == "Recharge":
  40.         amount_mana = int(type_commands[2])
  41.         our_hero_party[hero_name][1] += amount_mana
  42.         if our_hero_party[hero_name][1] > 200:
  43.             amount_mana -= our_hero_party[hero_name][1] - 200
  44.             our_hero_party[hero_name][1] = 200
  45.         return f"{hero_name} recharged for {amount_mana} MP!"
  46.     elif current_perform == "Heal":
  47.         healing = int(type_commands[2])
  48.         our_hero_party[hero_name][0] += healing
  49.         if our_hero_party[hero_name][0] > 100:
  50.             healing -= our_hero_party[hero_name][0] - 100
  51.             our_hero_party[hero_name][0] = 100
  52.         return f"{hero_name} healed for {healing} HP!"
  53.  
  54.  
  55. commands = input().split(" - ")
  56. while commands[0] != "End":
  57.     print(command_performing(commands))
  58.     commands = input().split(" - ")
  59.  
  60. for heroes_alive in our_hero_party:
  61.     print(f"""{heroes_alive}
  62.  HP: {our_hero_party[heroes_alive][0]}
  63.  MP: {our_hero_party[heroes_alive][1]}""")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement