export interface Game {
  id: number
  name: string
  slug: string
  generation: number
  region: string
  boxArtUrl: string | null
  releaseYear: number | null
  color: string | null
  versionGroupId: number | null
}

export interface Route {
  id: number
  name: string
  versionGroupId: number
  order: number
  parentRouteId: number | null
  pinwheelZone: number | null
  encounterMethods: string[]
}

export interface RouteWithChildren extends Route {
  children: Route[]
}

export interface Pokemon {
  id: number
  pokeapiId: number
  nationalDex: number
  name: string
  types: string[]
  spriteUrl: string | null
}

export interface RouteEncounter {
  id: number
  routeId: number
  pokemonId: number
  gameId: number
  encounterMethod: string
  encounterRate: number
  minLevel: number
  maxLevel: number
}

export interface RouteEncounterDetail extends RouteEncounter {
  pokemon: Pokemon
}

export type EncounterStatus = 'caught' | 'fainted' | 'missed'

export interface Encounter {
  id: number
  runId: number
  routeId: number
  pokemonId: number
  currentPokemonId: number | null
  nickname: string | null
  status: EncounterStatus
  catchLevel: number | null
  faintLevel: number | null
  deathCause: string | null
  isShiny: boolean
  caughtAt: string
}

export type RunStatus = 'active' | 'completed' | 'failed'

export interface NuzlockeRun {
  id: number
  gameId: number
  name: string
  status: RunStatus
  rules: NuzlockeRules
  startedAt: string
  completedAt: string | null
}

export interface RunDetail extends NuzlockeRun {
  game: Game
  encounters: EncounterDetail[]
}

export interface EncounterDetail extends Encounter {
  pokemon: Pokemon
  currentPokemon: Pokemon | null
  route: Route
}

export interface Evolution {
  id: number
  fromPokemonId: number
  toPokemon: Pokemon
  trigger: string
  minLevel: number | null
  item: string | null
  heldItem: string | null
  condition: string | null
  region: string | null
}

export interface CreateRunInput {
  gameId: number
  name: string
  rules?: NuzlockeRules
}

export interface UpdateRunInput {
  name?: string
  status?: RunStatus
  rules?: NuzlockeRules
}

export interface CreateEncounterInput {
  routeId: number
  pokemonId: number
  nickname?: string
  status: EncounterStatus
  catchLevel?: number
  isShiny?: boolean
}

export interface UpdateEncounterInput {
  nickname?: string
  status?: EncounterStatus
  faintLevel?: number
  deathCause?: string
  currentPokemonId?: number
}

// Boss battles
export type BossType = 'gym_leader' | 'elite_four' | 'champion' | 'rival' | 'evil_team' | 'other'

export interface BossPokemon {
  id: number
  pokemonId: number
  level: number
  order: number
  pokemon: Pokemon
}

export interface BossBattle {
  id: number
  versionGroupId: number
  name: string
  bossType: BossType
  badgeName: string | null
  badgeImageUrl: string | null
  levelCap: number
  order: number
  afterRouteId: number | null
  location: string
  spriteUrl: string | null
  pokemon: BossPokemon[]
}

export interface BossResult {
  id: number
  runId: number
  bossBattleId: number
  result: 'won' | 'lost'
  attempts: number
  completedAt: string | null
}

export interface CreateBossResultInput {
  bossBattleId: number
  result: 'won' | 'lost'
  attempts?: number
}

// Re-export for convenience
import type { NuzlockeRules } from './rules'
export type { NuzlockeRules }
