"""
AquaWar AI SDK for Python
"""


from __future__ import annotations

from typing import Any, overload


"""
`None`, `bool`, `int`, `float`, `str` 是 `Json` 类型\n
`Json` 类型组成的 `tuple`, `list`, `set`, `dict` 也是 `Json` 类型
"""
Json = Any


class fish_type:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: fish_type) -> int: ...
    def __init__(self: fish_type, value: int) -> None: ...
    def __int__(self: fish_type) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: fish_type, state: int) -> None: ...
    def __str__(self: fish_type) -> str: ...

    @property
    def name(self: fish_type) -> str: ...

    spray: fish_type  # = 1
    flame: fish_type  # = 2
    eel: fish_type  # = 3
    sunfish: fish_type  # = 4
    barracuda: fish_type  # = 5
    mobula: fish_type  # = 6
    turtle: fish_type  # = 7
    octopus: fish_type  # = 8
    whiteshark: fish_type  # = 9
    hammerhead: fish_type  # = 10
    clownfish: fish_type  # = 11
    imitator: fish_type  # = 12


spray = fish_type.spray  # 射水鱼
flame = fish_type.flame  # 喷火鱼
eel = fish_type.eel  # 电鳗
sunfish = fish_type.sunfish  # 翻车鱼
barracuda = fish_type.barracuda  # 梭子鱼
mobula = fish_type.mobula  # 蝠鲼
turtle = fish_type.turtle  # 海龟
octopus = fish_type.octopus  # 章鱼
whiteshark = fish_type.whiteshark  # 大白鲨
hammerhead = fish_type.hammerhead  # 锤头鲨
clownfish = fish_type.clownfish  # 小丑鱼
imitator = fish_type.imitator  # 拟态鱼


class active_skill:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: active_skill) -> int: ...
    def __init__(self: active_skill, value: int) -> None: ...
    def __int__(self: active_skill) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: active_skill, state: int) -> None: ...
    def __str__(self: active_skill) -> str: ...

    @property
    def name(self: active_skill) -> str: ...

    range_attack: active_skill  # = 0
    friend_attack: active_skill  # = 1
    critical_attack: active_skill  # = 2
    reduce_injury: active_skill  # = 3
    limit_critical: active_skill  # = 4
    weak_critical: active_skill  # = 5
    injury_tansfer: active_skill   # = 6


range_attack = active_skill.range_attack  # 射水鱼(spray)+电鳗(eel)
friend_attack = active_skill.friend_attack  # 喷火鱼(flame)+翻车鱼(sunfish)
critical_attack = active_skill.critical_attack  # 梭子鱼(barracuda)
reduce_injury = active_skill.reduce_injury  # 蝠鲼(mobula)+章鱼(octupus)
limit_critical = active_skill.limit_critical  # 海龟(turtle)
weak_critical = active_skill.weak_critical  # 大白鲨(whiteshark)+锤头鲨(hammerhead)
injury_tansfer = active_skill.injury_tansfer  # 小丑鱼(clownfish)


class passive_skill:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: passive_skill) -> int: ...
    def __init__(self: passive_skill, value: int) -> None: ...
    def __int__(self: passive_skill) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: passive_skill, state: int) -> None: ...
    def __str__(self: passive_skill) -> str: ...

    @property
    def name(self: passive_skill) -> str: ...

    injury_back: passive_skill  # = 0
    friend_injury_transfer: passive_skill  # = 1
    avoid_injury: passive_skill  # = 2
    shield: passive_skill  # = 3
    limit_heal: passive_skill  # = 4
    dead_boom: passive_skill  # = 5
    injury_transfer: passive_skill  # = 6


injury_back = passive_skill.injury_back  # 射水鱼(spray)+喷火鱼(flame)
# 电鳗(eel)+翻车鱼(sunfish)
friend_injury_transfer = passive_skill.friend_injury_transfer
avoid_injury = passive_skill.avoid_injury  # 梭子鱼(barracuda)+蝠鲼(mobula)
shield = passive_skill.shield  # 海龟(turtle)
limit_heal = passive_skill.limit_heal  # 章鱼(octopus)+大白鲨(whiteshark)
dead_boom = passive_skill.dead_boom  # 锤头鲨(hammerhead)
injury_transfer = passive_skill.injury_transfer  # 小丑鱼(clownfish)


class Fish:
    def __copy__(self: Fish) -> Fish: ...
    def __deepcopy__(self: Fish, memo: dict) -> Fish: ...

    @overload
    def __init__(self: Fish, id: int, hp: int, atk: int) -> None: ...

    def __init__(self: Fish) -> None:
        self.id: int = ...
        self.type: fish_type = ...
        self.hp: int = ...
        self.atk: int = ...
        self.skill_used: int = ...
        self.active: active_skill = ...
        self.passive: passive_skill = ...
        ...


class skill_type:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: skill_type) -> int: ...
    def __init__(self: skill_type, value: int) -> None: ...
    def __int__(self: skill_type) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: skill_type, state: int) -> None: ...
    def __str__(self: skill_type) -> str: ...

    @property
    def name(self: skill_type) -> str: ...

    aoe: skill_type  # = 0
    infight: skill_type  # = 1
    crit: skill_type  # = 2
    subtle: skill_type  # = 3
    normalattack: skill_type  # = 4


aoe = skill_type.aoe
infight = skill_type.infight
crit = skill_type.crit
subtle = skill_type.subtle
normalattack = skill_type.normalattack


class passive_type:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: passive_type) -> int: ...
    def __init__(self: passive_type, value: int) -> None: ...
    def __int__(self: passive_type) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: passive_type, state: int) -> None: ...
    def __str__(self: passive_type) -> str: ...

    @property
    def name(self: passive_type) -> str: ...

    counter: passive_type  # = 0
    deflect: passive_type  # = 1
    reduce: passive_type  # = 2
    heal: passive_type  # = 3
    explode: passive_type  # = 4


counter = passive_type.counter
deflect = passive_type.deflect
reduce = passive_type.reduce
heal = passive_type.heal
explode = passive_type.explode


max_length: int = 24


class ActionInfo:
    def __init__(self: ActionInfo) -> None:
        # 主动
        self.is_skill: bool = ...  # 是否是技能
        self.action_fish: int = ...  # 行动的鱼
        self.num_friend_targets: int = ...  # 友方目标个数
        self.num_enemy_targets: int = ...  # 敌方目标个数
        self.friend_targets: list[int] = ...  # 友方目标
        self.enemy_targets: list[int] = ...  # 敌方目标
        self.friend_excepted_injury: list[int] = ...  # 友方预期伤害
        self.enemy_excepted_injury: list[int] = ...  # 敌方预期伤害
        self.friend_expected_injury: list[int] = ...  # 友方预期伤害
        self.enemy_expected_injury: list[int] = ...  # 敌方预期伤害
        self.num_friend_injury: int = ...  # 友方受伤鱼的数量
        self.num_enemy_injury: int = ...  # 敌方受伤鱼的数量
        self.friend_injury_id: list[int] = ...  # 友方受伤鱼的位置编号
        self.enemy_injury_id: list[int] = ...  # 敌方受伤鱼的位置编号
        self.friend_injury: list[int] = ...  # 友方实际伤害
        self.enemy_injury: list[int] = ...  # 敌方实际伤害
        self.friend_injury_timestamp: list[int] = ...  # 友方受伤时间戳
        self.enemy_injury_timestamp: list[int] = ...  # 敌方受伤时间戳
        self.friend_injury_traceable: list[bool] = ...  # 友方受伤是否可追踪
        self.enemy_injury_traceable: list[bool] = ...  # 敌方受伤是否可追踪
        self.type: skill_type = ...
        # 被动
        self.num_friend_passives: int = ...  # 友方被动个数
        self.num_enemy_passives: int = ...  # 敌方被动个数
        self.friend_passives_id: list[int] = ...  # 友方触发被动的鱼的 id
        self.enemy_passives_id: list[int] = ...  # 敌方触发被动的鱼的 id
        self.friend_types: list[passive_type] = ...  # 友方触发被动类型
        self.enemy_types: list[passive_type] = ...  # 敌方触发被动类型
        self.friend_passive_value: list[float] = ...  # 友方减伤比/回血量
        self.enemy_passive_value: list[float] = ...  # 敌方减伤比/回血量
        self.friend_passives_timestamp: list[int] = ...  # 友方触发被动时间戳
        self.enemy_passives_timestamp: list[int] = ...  # 敌方触发被动时间戳

    def clear_skill(self: ActionInfo) -> None: ...
    def clear_hit(self: ActionInfo) -> None: ...
    def clear_passive(self: ActionInfo) -> None: ...
    def clear(self: ActionInfo) -> None: ...
    def is_empty(self: ActionInfo) -> bool: ...


class AssertInfo:
    def __init__(self: AssertInfo) -> None:
        self.assertPos: int = ...
        self.assertContent: int = ...
        self.assertResult: bool = ...

    def clear(self: AssertInfo) -> None: ...
    def is_empty(self: AssertInfo) -> bool: ...


class Game:
    """
    游戏局面
    """

    def __init__(self: Game,
                 friend1: Fish, friend2: Fish, friend3: Fish, friend4: Fish,
                 enemy1: Fish, enemy2: Fish, enemy3: Fish, enemy4: Fish,
                 avatar_id: int, first_mover: bool, round: int,
                 enemy_action: ActionInfo, my_action: ActionInfo,
                 enemy_assert: AssertInfo, my_assert: AssertInfo,
                 round1_win: bool, round2_win: bool, round3_win: bool,
                 last_round_finish_reason: int, state_limit_exceed: bool
                 ) -> None: ...

    @property
    def my_fish(self: Game) -> list[Fish]: ...
    @property
    def enemy_fish(self: Game) -> list[Fish]: ...
    @property
    def avatar_id(self: Game) -> int: ...
    @property
    def first_mover(self: Game) -> bool: ...
    @property
    def enemy_action(self: Game) -> ActionInfo: ...
    @property
    def my_action(self: Game) -> ActionInfo: ...
    @property
    def enemy_assert(self: Game) -> AssertInfo: ...
    @property
    def my_assert(self: Game) -> AssertInfo: ...
    @property
    def round(self: Game) -> int: ...
    @property
    def round1_win(self: Game) -> bool: ...
    @property
    def round2_win(self: Game) -> bool: ...
    @property
    def round3_win(self: Game) -> bool: ...
    @property
    def last_round_finish_reason(self: Game) -> int: ...
    @property
    def state_limit_exceed(self: Game) -> bool: ...


class err_type:
    def __eq__(self: object, other: object) -> bool: ...
    def __getstate__(self: object) -> int: ...
    def __hash__(self: object) -> int: ...
    def __index__(self: err_type) -> int: ...
    def __init__(self: err_type, value: int) -> None: ...
    def __int__(self: err_type) -> int: ...
    def __ne__(self: object, other: object) -> bool: ...
    def __repr__(self: object) -> str: ...
    def __setstate__(self: err_type, state: int) -> None: ...
    def __str__(self: err_type) -> str: ...

    @property
    def name(self: err_type) -> str: ...

    err_target: err_type  # = 0
    err_target_out_of_range: err_type  # = 1
    err_action_type: err_type  # = 2
    err_action_fish: err_type  # = 3
    err_action_not_choose: err_type  # = 4
    err_fish_not_choose: err_type  # = 5
    success: err_type  # = 6


err_target = err_type.err_target
err_target_out_of_range = err_type.err_target_out_of_range
err_action_type = err_type.err_action_type
err_action_fish = err_type.err_action_fish
err_action_not_choose = err_type.err_action_not_choose
err_fish_not_choose = err_type.err_fish_not_choose
success = err_type.success


class Action:
    """
    -1 代表未初始化，-2 代表目标为全体
    """

    def __init__(self: Action, game: Game) -> None: ...

    def set_action_type(self: Action, action_type: int) -> err_type: ...
    def set_action_fish(self: Action, fish_id: int) -> err_type: ...
    def set_enemy_target(self: Action, enemy_id: int) -> err_type: ...
    def set_friend_target(self: Action, friend_id: int) -> err_type: ...
    def get_action_type(self: Action) -> int: ...
    def get_action_fish(self: Action) -> int: ...
    def get_enemy_target(self: Action) -> int: ...
    def get_friend_target(self: Action) -> int: ...


class AIClient:
    def __init__(self: AIClient) -> None: ...

    def random(self: AIClient, l: float, r: float) -> float: ...
    def debug_msg(self: AIClient, str: str) -> None: ...
    def clear_msg(self: AIClient) -> None: ...

    def sendLen(self: AIClient, s: str) -> None:
        """
        发送消息前需要先发送长度\n
        调用 `sendLen` 函数
        """
        ...

    def sendrecv_msg(self: AIClient, s: str) -> None:
        """发送消息"""
        ...

    def listen(self: AIClient) -> None:
        """接收消息"""
        ...

    # sdk 函数
    def get_my_remain_fishes(self: AIClient) -> list[int]:
        """获得自己剩余的鱼的编号"""
        ...

    def get_enemy_id(self: AIClient, pos: int) -> int:
        """获得敌方一条鱼的 id"""
        ...

    def get_enemy_hp(self: AIClient, pos: int) -> int:
        """获得敌方一条鱼的 hp"""
        ...
        
    # def get_enemy_atk(self: AIClient, pos: int) -> int:
    #     """获得敌方一条鱼的 atk"""
    #     ...

    def get_my_id(self: AIClient, pos: int) -> int: ...

    def get_my_hp(self: AIClient, pos: int) -> int:
        """获得我方一条鱼的 hp"""
        ...

    def get_my_atk(self: AIClient, pos: int) -> int:
        """获得我方一条鱼的 atk"""
        ...

    def get_lowest_health_enemy(self: AIClient) -> int: ...

    def get_lowest_health_enemies(self: AIClient) -> list[int]: ...

    def get_enemy_living_fishes(self: AIClient) -> list[int]:
        """获得敌方剩余存活的鱼的编号"""
        ...

    def get_my_living_fishes(self: AIClient) -> list[int]:
        """获得自己剩余存活的鱼的编号"""
        ...

    def get_my_living_ally(self: AIClient, pos: int) -> list[int]:
        """获得自己一条鱼的其余存活队友"""
        ...

    def get_avatar_id(self: AIClient) -> int:
        """获得己方拟态鱼本轮模仿的鱼的编号"""
        ...

    def get_first_mover(self: AIClient) -> bool:
        """获取己方这一轮是否是先手"""
        ...

    def get_skill_used(self: AIClient, pos: int) -> int:
        """获得自己一条鱼的主动技能使用次数"""
        ...

    def auto_valid_action(self: AIClient, pos: int, action: Action) -> Action:
        """自动为一个位置的鱼选取合法行动目标，优先高概率使用主动技能，若不可能合法则使用普通攻击"""
        ...

    # 用户编写 AI 的函数
    def Pick(self: AIClient, game: Game) -> list[int]:
        """用于完成选鱼上场的操作"""
        ...

    def Assert(self: AIClient, game: Game) -> tuple[int, int]:
        """
        用于断言操作
        第一个数字返回 -1 表示不使用断言
        """
        ...

    def Act(self: AIClient, game: Game) -> Action:
        """
        用于行动操作，需要返回一个 `int` 类型的二维向量，该向量必须有四行\n
        第一个向量的第一个数字表示行动类型\n
        第二个向量的第一个数字表示友方鱼的位置\n
        若 `type == 0`：\n
            第三个向量的第一个数字代表需要攻击的敌方鱼位置
        若 `type == 1`：\n
            第三个向量代表友方鱼目标\n
            第四个向量代表敌方鱼作用目标\n
        返回值是行动类型与选取的友方鱼类\n
        \n
        示例：\n
        >>> action = [[0 for _ in range(4)] for _ in range(4)]
        然后只需以下标修改各向量内容即可\n
        """
        ...

    # 解析函数
    def parseGameInfo(self: AIClient, gameInfo: Json) -> None: ...
    def parseEnemyActionInfo(self: AIClient, actionInfo: Json) -> None: ...
    def parseMyActionInfo(self: AIClient, actionInfo: Json) -> None: ...
    def parseEnemyAssert(self: AIClient, assertInfo: Json) -> None: ...
    def parseMyAssert(self: AIClient, assertInfo: Json) -> None: ...

    def updateGame(self: AIClient) -> None:
        """更新函数"""
        ...

    # 动作函数
    def Action_Pick(self: AIClient) -> None: ...
    def Action_Assert(self: AIClient) -> None: ...
    def Action_Action(self: AIClient) -> None: ...
    def Action_Finish(self: AIClient) -> None: ...

    def run(self: AIClient) -> None:
        """回合制循环"""
        ...
