from datetime import datetime

from app.schemas.base import CamelModel
from app.schemas.pokemon import PokemonResponse


class BossPokemonResponse(CamelModel):
    id: int
    pokemon_id: int
    level: int
    order: int
    condition_label: str | None
    pokemon: PokemonResponse


class BossBattleResponse(CamelModel):
    id: int
    version_group_id: int
    name: str
    boss_type: str
    specialty_type: str | None
    badge_name: str | None
    badge_image_url: str | None
    level_cap: int
    order: int
    after_route_id: int | None
    location: str
    section: str | None
    sprite_url: str | None
    pokemon: list[BossPokemonResponse] = []


class BossResultResponse(CamelModel):
    id: int
    run_id: int
    boss_battle_id: int
    result: str
    attempts: int
    completed_at: datetime | None


# --- Input schemas ---


class BossBattleCreate(CamelModel):
    name: str
    boss_type: str
    specialty_type: str | None = None
    badge_name: str | None = None
    badge_image_url: str | None = None
    level_cap: int
    order: int
    after_route_id: int | None = None
    location: str
    section: str | None = None
    sprite_url: str | None = None


class BossBattleUpdate(CamelModel):
    name: str | None = None
    boss_type: str | None = None
    specialty_type: str | None = None
    badge_name: str | None = None
    badge_image_url: str | None = None
    level_cap: int | None = None
    order: int | None = None
    after_route_id: int | None = None
    location: str | None = None
    section: str | None = None
    sprite_url: str | None = None


class BossPokemonInput(CamelModel):
    pokemon_id: int
    level: int
    order: int
    condition_label: str | None = None


class BossResultCreate(CamelModel):
    boss_battle_id: int
    result: str
    attempts: int = 1


class BossReorderItem(CamelModel):
    id: int
    order: int


class BossReorderRequest(CamelModel):
    bosses: list[BossReorderItem]


class BossResultUpdate(CamelModel):
    result: str | None = None
    attempts: int | None = None
