
You’re given N animals, each with a role and combat stats as in the game Animal Kaizer. Then you’re given a sequence of T attack commands. Process the attacks in order using the combat rules below. After all attacks, print every animal that is still alive in order.
Roles & combat rules:
Ignores 25% of the defender’s defense (i.e., defender’s effective defense is defense * 0.75).
When a Tank is the defender, it takes half damage (after defense is applied).
Attack power is self.atk + 0.8 * defender.atk (before defense and anything else).
If a defender’s hp drops to 0 or below, set it to exactly 0 and set that animal's state to Dead.
If the attacker is not Alive, print
<attacker_name> is already dead
and do nothing.
Similarly, if the defender is not Alive, print
<defender_name> is already dead
and do nothing.
You can start from this code:
> Note: Final applied damage is truncated to an integer (floor).
The first line will contain 2 numbers:
T will be the number of attacks that will be launched.N will be the number of animals you are given. The next N line each contains:
{name} {atk} {hp} {defense} {role}
Where:
Name is unique string with no spaces.atk, hp, defense are integers.role is either {"Warrior", "Tank", "Mage"}The next T line each contains:
{animal_one} {animal_two}
where animal_one attacks animal_two
animal_one and animal_two is guaranteed to be one of the N animals given before.
After all T attacks, print all animals that are still alive (in input order)
{animal_role} {animal_name}: {animal_hp}