package de.nowchess.backcore.dto

import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonInclude.Include

case class PlayerInfoDto(id: String, displayName: String)

case class GameStateResponse(
    fen: String,
    pgn: String,
    turn: String,
    status: String,
    @JsonInclude(Include.NON_ABSENT) winner: Option[String],
    moves: List[String],
    undoAvailable: Boolean,
    redoAvailable: Boolean,
)

case class GameFullResponse(
    gameId: String,
    white: PlayerInfoDto,
    black: PlayerInfoDto,
    state: GameStateResponse,
)

case class OkResponse(ok: Boolean = true)

@JsonInclude(Include.NON_ABSENT)
case class ApiErrorResponse(
    code: String,
    message: String,
    field: Option[String] = None,
)

// Requests
case class CreateGameRequest(
    white: Option[PlayerInfoDto] = None,
    black: Option[PlayerInfoDto] = None,
)

case class ImportFenRequest(
    fen: String = "",
    white: Option[PlayerInfoDto] = None,
    black: Option[PlayerInfoDto] = None,
)

case class ImportPgnRequest(pgn: String = "")

case class LegalMoveDto(
    from: String,
    to: String,
    uci: String,
    moveType: String,
    @JsonInclude(Include.NON_ABSENT) promotion: Option[String] = None,
)

case class LegalMovesResponse(moves: List[LegalMoveDto])
