import type { Container } from 'pixi.js'

export interface PlayerDto {
  id: string
  name: string
  score: number
  hand: TileDto[]
  teamedWith: PlayerDto | null
  ready: boolean
}

export interface TileDto {
  id: string
  pips?: [number, number]
  orientation?: string
  x?: number
  y?: number
  width?: number
  height?: number
  playerId?: string
}
export interface MatchSessionDto {
  _id: string
  id: string
  name: string
  creator: string
  players: PlayerDto[]
  seed: string
  waitingForPlayers: boolean
  mode: string
  options: MatchSessionOptions
  sessionInProgress: boolean
  status: string
  maxPlayers: number
  numPlayers: number
  waitingSeconds: number
  scoreboard: { id: string; name: string; score: number }[]
  matchWinner: PlayerDto | null
  matchInProgress: boolean
  playersReady: number
  gameSummaries: GameSummary[]
  room: string
}

export interface GameDto {
  id: string
  players: PlayerDto[]
  tilesInBoneyard: TileDto[]
  currentPlayer: PlayerDto | null
  tilesInBoard: TileDto[]
  gameInProgress: boolean
  winner?: any
  gameBlocked: boolean
  gameTied: boolean
  gameId: string
  tileSelectionPhase: boolean
  boardFreeEnds: number[]
  lastMove: Movement
}

export interface Movement {
  id: string
  type: string
  tile?: TileDto
  playerId: string
  direction?: string
  x?: number
  y?: number
}

export interface ContainerOptions {
  width?: number
  height?: number
  x?: number
  y?: number
  color?: number
  visible?: boolean
  parent?: Container
  alpha?: number
}

export interface Dimension {
  width?: number
  height?: number
  x?: number
  y?: number
}

export interface SocketEvent {
  event: string
  data: any
}

export interface AnimationOptions {
  x?: number
  y?: number
  rotation?: number
  scale?: number
  duration?: number
  width?: number
  height?: number
}

export interface ScreenOptions {
  boardScale: number
  handScale: number
  width: number
  height: number
}

export interface MatchSessionOptions {
  screen?: ScreenOptions
  seed?: string
  background: string
  teamed: boolean
  winTarget: number
  winType: 'points' | 'rounds'
  sessionName: string
  numPlayers: 1 | 2 | 3 | 4
  turnWaitSeconds: number
}

export interface GameSummary {
  gameId: string
  isBlocked: boolean
  isTied: boolean
  winner: PlayerDto
  score: { id: string; name: string; score: number }[]
  players?: PlayerDto[]
  board: TileDto[]
  boneyard: TileDto[]
}

export interface Config {
  waitMillisToShowSummary: number
  activeHandStrokeColor: number
}
