15095 - Hunter × Pokémon: Nen Dimensional Warehouse   

Description

Hunter × Pokémon: Nen Arena

Cabi is a student at NTHU, who recently has faced some trouble with linear algebra.

This month, Cabi received his first midterm exam for Linear Algebra, and he was upset about getting such a bad score. Even worse, he has to face his second Linear Algebra midterm on 11/23 ._..

To make his mood better, he decided to torture I2P students, Cabi decided to take a break by watching Hunter × Hunter while grinding Pokémon battles.

However, being an I2P TA without empathy, Cabi realized that standard Pokémon battles are way too predictable. "What if Hunters command Pokémon using their own Nen (念)-type brains?" he thought. As Hisoka's (西索) famous Nen-type personality analysis goes:

  • Enhancers (強化系) are simple and earnest — they blindly spam their strongest attack without overthinking.
  • Emitters (放出系) are impatient and careless — they rush to finish the fight and completely ignore healing.
  • Transmuters (變化系) are fickle and deceitful — they constantly switch tactics to trick their opponents.
  • Manipulators (操作系) are logical and go at their own pace — they follow a strict mathematical formula for resource efficiency.
  • Conjurers (具現化系) are high-strung and overly cautious — they panic the moment they lose even 1 HP and prioritize safe, low-cooldown moves.
  • Specialists (特質系) are individualistic with a charismatic leader's aura — they refuse to follow conventional rules, living on the edge before unleashing flashy ultimate moves.

(Note: This is entirely Hisoka's arbitrary prejudice—and now it is your OOP assignment.)

An idea crossed Cabi's mind. As an I2P TA without empathy, he decided to let every I2P student implement this battle simulator for him, he thought that will be a piece of cake for these geniuses.


Now, your task is to help Cabi solve the problem. Write an object-oriented program to simulate a turn-based Pokémon battle commanded by two Hunters.

All arithmetic in this problem uses integer division (//) to avoid floating-point precision issues. Here is how the battle system works:

  1. Cooldown & Resource Management (Skill):
    • Each skill has max_cd (cooldown turns) and max_pp (maximum uses). Initially, current_cd = 0 and current_pp = max_pp.
    • At the start of a Hunter's turn, every skill's current_cd decreases by (clamped at ).
    • A skill is available if and only if current_cd == 0 and current_pp > 0.
    • When used, current_pp decreases by and current_cd is set to max_cd.
  2. Pokémon Types & Damage Calculation (Pokemon):
    • Standard damage formula: effective_def = (defense // 2) if ignore_def_half else defense, and actual_dmg = max(1, raw_dmg - effective_def).
    • If no skills are available (chosen is None), the Pokémon uses struggle, dealing raw_dmg = max(1, atk // 2) (ignore_def_half=False).
    • PowerPokemon:
      • "Attack": raw_dmg = ((atk + skill.power) * 12) // 10, ignore_def_half=False.
      • "Pierce": raw_dmg = atk + skill.power, ignore_def_half=False.
      • "Heal": heals self by skill.power.
    • MysticPokemon:
      • "Attack": raw_dmg = atk + skill.power, ignore_def_half=False.
      • "Pierce": raw_dmg = atk + skill.power, ignore_def_half=True.
      • "Heal": heals self by skill.power.
    • TankPokemon:
      • Overrides take_damage: reduces incoming raw_dmg by first (mitigated_raw = (raw_dmg * 8) // 10), then applies standard defense calculation.
      • "Attack" or "Pierce": raw_dmg = atk + skill.power, ignore_def_half=False.
      • "Heal": heals self by (skill.power * 3) // 2.
  3. Hunter Nen Brains (Hunter):
    • Each Hunter owns a Pokemon and tracks personal action turns (turn_count, incremented by at the start of take_turn).
    • If available_skills is empty, all Hunters return None.
    • EnhancerHunter: Filters for offensive skills (skill_type in ("Attack", "Pierce")); if none exist, considers all available_skills. Picks the one with the highest power (tie-breaker: smaller skill index).
    • EmitterHunter: If enemy_pokemon.defense >= 15 and at least one "Pierce" skill is available, picks the "Pierce" skill with the highest power (tie-breaker: smaller skill index). Otherwise, behaves like EnhancerHunter.
    • TransmuterHunter: On odd personal turns (turn_count % 2 == 1), picks the available skill with the lowest power (tie-breaker: larger skill index). On even personal turns (turn_count % 2 == 0), picks the available skill with the highest current_pp (tie-breaker: smaller max_cd, then smaller skill index).
    • ManipulatorHunter: If pokemon.hp < pokemon.max_hp // 2 and at least one "Heal" skill is available, picks the "Heal" skill with the highest power (tie-breaker: smaller skill index). Otherwise, filters for offensive skills (fallback: all available) and picks the one maximizing power * current_pp (tie-breaker: smaller skill index).
    • ConjurerHunter: If pokemon.hp < pokemon.max_hp and at least one "Heal" skill is available, picks the "Heal" skill with the highest power (tie-breaker: smaller skill index). Otherwise, filters for offensive skills (fallback: all available) and picks the one with the lowest max_cd (tie-breaker: highest power, then smaller skill index).
    • SpecialistHunter: On every 3rd personal turn (turn_count % 3 == 0), picks from all available_skills the one with the highest max_cd (tie-breaker: highest power, then smaller skill index). On all other turns, picks from all available_skills the one with the lowest current_pp (tie-breaker: highest power, then smaller skill index).
  4. Arena Loop (BattleArena):
    • Loops global turn from to max_turns (inclusive). Before each turn, if either Pokémon has is_alive == False, stops immediately.
    • Odd global turns: hunter1.take_turn(hunter2); even global turns: hunter2.take_turn(hunter1).
    • After the loop, the Hunter whose Pokémon has strictly higher hp wins; otherwise "Draw".

As a kind TA, Cabi has already written the skeleton structure for you, but some of the classes and methods are still missing. Your task is to complete those classes.

Variables

  • max_turns: maximum number of single-action turns in the battle (int).
  • current_cd, current_pp: managed via @property getters and setters on Skill, automatically clamped to [0, max_cd] and [0, max_pp].
  • is_available: read-only @property on Skill returning bool (current_cd == 0 and current_pp > 0).
  • hp: managed via @property getter and setter on Pokemon, automatically clamped to [0, max_hp].
  • is_alive: read-only @property on Pokemon returning bool (hp > 0).
  • turn_count: personal action counter on Hunter, initialized to 0.

Example for the Battle Mechanics:

Suppose Gon (EnhancerHunter) commands Charizard (PowerPokemon, max_hp=120, atk=25, def=10) with Flamethrower (Attack, power=30, max_cd=2, max_pp=2) against Hisoka (TransmuterHunter) commanding Gengar (MysticPokemon, max_hp=110, atk=22, def=8):

  • Global Turn 1 (Gon's Turn 1): Gon picks his highest-power offensive skill Flamethrower. PowerPokemon boosts "Attack" raw damage by : ((25 + 30) * 12) // 10 = 66. Gengar takes max(1, 66 - 8) = 58 damage (hp: 110 -> 52).
  • Global Turn 2 (Hisoka's Turn 1): Being odd turn (turn_count == 1), Hisoka feints with his lowest-power skill Lick (power=12), dealing max(1, (22 + 12) - 10) = 24 damage (Charizard hp: 120 -> 96).

Classes to Implement

To build the arena, you need to implement the following classes and methods:

  • Skill:
    • __init__(self, name: str, skill_type: str, power: int, max_cd: int, max_pp: int)
    • @property & setters for current_cd and current_pp; read-only @property is_available.
    • consume(self) -> None and tick_cooldown(self) -> None.
    • @classmethod def from_string(cls, line: str) -> "Skill": Parses "<name> <skill_type> <power> <max_cd> <max_pp>".
    • __repr__(self) -> str: Returns Skill(name='<name>', type='<skill_type>', power=<power>, cd=<current_cd>/<max_cd>, pp=<current_pp>/<max_pp>).
  • Pokemon(ABC) & Subclasses (PowerPokemon, MysticPokemon, TankPokemon):
    • __init__(self, name: str, max_hp: int, atk: int, defense: int, skills: List[Skill])
    • @property & setter for hp; read-only @property is_alive.
    • prepare_turn(self) -> None, get_available_skills(self) -> List[Skill], heal(self, amount: int) -> None, take_damage(self, raw_dmg: int, ignore_def_half: bool = False) -> int, struggle(self, target: "Pokemon") -> None.
    • @abstractmethod def execute_skill(self, skill: Skill, target: "Pokemon") -> None implemented in each subclass.
    • @classmethod def create(cls, poke_type: str, poke_name: str, max_hp: int, atk: int, defense: int, skills: List[Skill]) -> "Pokemon".
    • __repr__(self) -> str: Returns <ClassName>(name='<name>', hp=<hp>/<max_hp>, atk=<atk>, def=<defense>).
  • Hunter(ABC) & Subclasses (EnhancerHunter, EmitterHunter, TransmuterHunter, ManipulatorHunter, ConjurerHunter, SpecialistHunter):
    • __init__(self, name: str, nen_type: str, pokemon: Pokemon) and take_turn(self, opponent: "Hunter") -> None.
    • @abstractmethod def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill] implemented in each subclass.
    • @classmethod def create(cls, nen_type: str, hunter_name: str, pokemon: Pokemon) -> "Hunter".
    • __repr__(self) -> str: Returns <ClassName>(name='<name>', turn=<turn_count>, pokemon=<repr(pokemon)>).
  • BattleArena:
    • __init__(self, hunter1: Hunter, hunter2: Hunter, max_turns: int) and run(self) -> str.

Template code

from abc import ABC, abstractmethod
from typing import Dict, List, Optional, Type
import sys


class Skill:
    def __init__(self, name: str, skill_type: str, power: int, max_cd: int, max_pp: int):
        # TODO
        pass

    @property
    def current_cd(self) -> int:
        # TODO
        pass

    @current_cd.setter
    def current_cd(self, value: int) -> None:
        # TODO
        pass

    @property
    def current_pp(self) -> int:
        # TODO
        pass

    @current_pp.setter
    def current_pp(self, value: int) -> None:
        # TODO
        pass

    @property
    def is_available(self) -> bool:
        # TODO
        pass

    def consume(self) -> None:
        # TODO
        pass

    def tick_cooldown(self) -> None:
        # TODO
        pass

    @classmethod
    def from_string(cls, line: str) -> "Skill":
        # TODO
        pass

    def __repr__(self) -> str:
        # TODO
        pass


class Pokemon(ABC):
    def __init__(self, name: str, max_hp: int, atk: int, defense: int, skills: List[Skill]):
        # TODO
        pass

    @property
    def hp(self) -> int:
        # TODO
        pass

    @hp.setter
    def hp(self, value: int) -> None:
        # TODO
        pass

    @property
    def is_alive(self) -> bool:
        # TODO
        pass

    def prepare_turn(self) -> None:
        # TODO
        pass

    def get_available_skills(self) -> List[Skill]:
        # TODO
        pass

    def heal(self, amount: int) -> None:
        # TODO
        pass

    def take_damage(self, raw_dmg: int, ignore_def_half: bool = False) -> int:
        # TODO
        pass

    def struggle(self, target: "Pokemon") -> None:
        # TODO
        pass

    @abstractmethod
    def execute_skill(self, skill: Skill, target: "Pokemon") -> None:
        pass

    @classmethod
    def create(
        cls,
        poke_type: str,
        poke_name: str,
        max_hp: int,
        atk: int,
        defense: int,
        skills: List[Skill],
    ) -> "Pokemon":
        # TODO
        pass

    def __repr__(self) -> str:
        # TODO
        pass


class PowerPokemon(Pokemon):
    def execute_skill(self, skill: Skill, target: "Pokemon") -> None:
        # TODO
        pass


class MysticPokemon(Pokemon):
    def execute_skill(self, skill: Skill, target: "Pokemon") -> None:
        # TODO
        pass


class TankPokemon(Pokemon):
    def take_damage(self, raw_dmg: int, ignore_def_half: bool = False) -> int:
        # TODO
        pass

    def execute_skill(self, skill: Skill, target: "Pokemon") -> None:
        # TODO
        pass


class Hunter(ABC):
    def __init__(self, name: str, nen_type: str, pokemon: Pokemon):
        # TODO
        pass

    def take_turn(self, opponent: "Hunter") -> None:
        # TODO
        pass

    @abstractmethod
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        pass

    @classmethod
    def create(cls, nen_type: str, hunter_name: str, pokemon: Pokemon) -> "Hunter":
        # TODO
        pass

    def __repr__(self) -> str:
        # TODO
        pass


class EnhancerHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class EmitterHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class TransmuterHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class ManipulatorHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class ConjurerHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class SpecialistHunter(Hunter):
    def choose_skill(self, available_skills: List[Skill], enemy_pokemon: Pokemon) -> Optional[Skill]:
        # TODO
        pass


class BattleArena:
    def __init__(self, hunter1: Hunter, hunter2: Hunter, max_turns: int):
        # TODO
        pass

    def run(self) -> str:
        # TODO
        pass


def parse_hunter(input_fn) -> Hunter:
    h_name, nen_type = input_fn().split()
    p_line = input_fn().split()
    p_name, p_type = p_line[0], p_line[1]
    max_hp, atk, defense, num_skills = map(int, p_line[2:])
    skills = [Skill.from_string(input_fn()) for _ in range(num_skills)]
    pokemon = Pokemon.create(p_type, p_name, max_hp, atk, defense, skills)
    return Hunter.create(nen_type, h_name, pokemon)


if __name__ == "__main__":
    input_fn = sys.stdin.readline
    max_turns = int(input_fn().strip())
    h1 = parse_hunter(input_fn)
    h2 = parse_hunter(input_fn)

    arena = BattleArena(h1, h2, max_turns)
    winner = arena.run()

    print(f"{h1.name} ({h1.pokemon.name}): {h1.pokemon.hp}/{h1.pokemon.max_hp}")
    print(f"{h2.name} ({h2.pokemon.name}): {h2.pokemon.hp}/{h2.pokemon.max_hp}")
    print(f"Winner: {winner}")

Input

The first line contains a single integer max_turns.
Then follow two Hunter blocks (for Hunter 1 and Hunter 2), each structured as:

  • First line: hunter_name nen_type (nen_type {"Enhancer", "Emitter", "Transmuter", "Manipulator", "Conjurer", "Specialist"})
  • Second line: poke_name poke_type max_hp atk defense num_skills (poke_type {"Power", "Mystic", "Tank"})
  • Next num_skills lines: skill_name skill_type power max_cd max_pp (skill_type {"Attack", "Pierce", "Heal"})

Constraints

  • All names consist of alphanumeric characters without spaces.

Output

Output 3 lines:

  • Line 1: <hunter1_name> (<poke1_name>): <poke1_hp>/<poke1_max_hp>
  • Line 2: <hunter2_name> (<poke2_name>): <poke2_hp>/<poke2_max_hp>
  • Line 3: Winner: <winner_name_or_Draw>

Sample Input 1  Download

Sample Output 1  Download

Sample Input 2  Download

Sample Output 2  Download

Sample Input  Download

Sample Output  Download




Discuss