export type ChallengeStatus = 'created' | 'pending' | 'accepted' | 'declined' | 'cancelled' | 'expired';

export type PlayerColor = 'white' | 'black' | 'random';

export interface Player {
    id: string;
    name: string;
    rating: number;
}

export interface TimeControl {
    type: string | null;
    limit: number | null;
    increment: number | null;
}

export interface Challenge {
    id: string;
    challenger: Player;
    destUser: Player;
    variant: string;
    color: PlayerColor;
    timeControl: TimeControl;
    status: ChallengeStatus;
    declineReason: string | null;
    gameId: string | null;
    expiresAt: string;
    createdAt: string;
}

export interface SendChallengeRequest {
    timeControl: {
        limitSeconds: number;
        incrementSeconds: number;
    };
    color?: PlayerColor;
    ttlSeconds?: number;
}

export interface ListChallengesResponse {
    'in'?: Challenge[];
    'out'?: Challenge[];
    incoming?: Challenge[];
    outgoing?: Challenge[];
}

export interface DeclineChallengeRequest {
    reason?: string;
}
