import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsEnum, IsNumber, IsString, ValidateNested } from 'class-validator';

export class LeagueScoringPresetTimingDefaultsDTO {
  @ApiProperty()
  @IsNumber()
  practiceMinutes!: number;

  @ApiProperty()
  @IsNumber()
  qualifyingMinutes!: number;

  @ApiProperty()
  @IsNumber()
  sprintRaceMinutes!: number;

  @ApiProperty()
  @IsNumber()
  mainRaceMinutes!: number;

  @ApiProperty()
  @IsNumber()
  sessionCount!: number;
}

export class LeagueScoringPresetDTO {
  @ApiProperty()
  @IsString()
  id!: string;

  @ApiProperty()
  @IsString()
  name!: string;

  @ApiProperty()
  @IsString()
  description!: string;

  @ApiProperty({ enum: ['driver', 'team', 'nations', 'trophy'] })
  @IsEnum(['driver', 'team', 'nations', 'trophy'])
  primaryChampionshipType!: 'driver' | 'team' | 'nations' | 'trophy';

  @ApiProperty()
  @IsString()
  sessionSummary!: string;

  @ApiProperty()
  @IsString()
  bonusSummary!: string;

  @ApiProperty()
  @IsString()
  dropPolicySummary!: string;

  @ApiProperty({ type: LeagueScoringPresetTimingDefaultsDTO })
  @ValidateNested()
  @Type(() => LeagueScoringPresetTimingDefaultsDTO)
  defaultTimings!: LeagueScoringPresetTimingDefaultsDTO;
}