14784 - Animal Kaizer   

Description

Animal Kaiser Official Website

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:

  • Warrior

           Ignores 25% of the defender’s defense (i.e., defender’s effective defense is defense * 0.75).

  • Tank

           When a Tank is the defender, it takes half damage (after defense is applied).

  • Mage

           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:

class Animal():
    def __init__(self, name: str, atk: int, hp: int, defense: int, role: str):
        self.name = name
        self.atk = atk
        self.hp = hp
        self.defense = defense
        self.role = role
        self.state = "Alive"
    
        
    @property
    def state(self):
        return self._state
    
    @state.setter
    def state(self, state):
        if state == "Alive" or state == "Dead":
            self._state = state 

    def __str__(self):
        return f"{self.role} {self.name}: {self.hp}"
    
    def attack(self, animal: "Animal"):
        # Write your code here
        pass
    
# Write your code here
line_one = input().split()

 

> Note: Final applied damage is truncated to an integer (floor).

Input

The first line will contain 2 numbers:

  • The first number T will be the number of attacks that will be launched.
  • The second number 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.

Output

After all T attacks, print all animals that are still alive (in input order)

{animal_role} {animal_name}: {animal_hp}

Sample Input  Download

Sample Output  Download

Tags




Discuss