from datetime import datetime

from app.schemas.base import CamelModel
from app.schemas.encounter import EncounterDetailResponse
from app.schemas.game import GameResponse


class RunCreate(CamelModel):
    game_id: int
    name: str
    rules: dict = {}


class RunUpdate(CamelModel):
    name: str | None = None
    status: str | None = None
    rules: dict | None = None
    hof_encounter_ids: list[int] | None = None


class RunResponse(CamelModel):
    id: int
    game_id: int
    name: str
    status: str
    rules: dict
    hof_encounter_ids: list[int] | None = None
    started_at: datetime
    completed_at: datetime | None


class RunGenlockeContext(CamelModel):
    genlocke_id: int
    genlocke_name: str
    leg_order: int
    total_legs: int
    is_final_leg: bool
    retired_pokemon_ids: list[int] = []


class RunDetailResponse(RunResponse):
    game: GameResponse
    encounters: list[EncounterDetailResponse] = []
    genlocke: RunGenlockeContext | None = None
    transfer_encounter_ids: list[int] = []
