import {
  IsNotEmpty,
  IsString,
  Length,
  IsDateString,
  IsNumber,
} from 'class-validator';
import { ObjectivePointEntity } from './game.entity';

export class GameDTO {
  @IsString()
  @IsNotEmpty()
  @Length(3, 30)
  name: string;
  @IsNotEmpty()
  @Length(1, 255)
  desc: string;
  @IsNotEmpty()
  center: JSON;
  map?: JSON;
  nodesettings?: JSON;
  @IsDateString()
  @IsNotEmpty()
  startdate: string;
  @IsDateString()
  @IsNotEmpty()
  enddate: string;
  factions?: FactionDTO[];
  objective_points?: FlagboxDTO[];
}

export class newGameDTO {
  @IsString()
  @IsNotEmpty()
  @Length(3, 30)
  name: string;
  @IsString()
  @IsNotEmpty()
  @Length(1, 255)
  desc: string;
  @IsNotEmpty()
  center: JSON;
  @IsDateString()
  @IsNotEmpty()
  startdate: string;
  @IsDateString()
  @IsNotEmpty()
  enddate: string;
}

export class FactionDTO {
  @IsString()
  @IsNotEmpty()
  @Length(2, 15)
  factionName: string;
  factionPassword: string;
  multiplier?: number;
  game: GameDTO;
}

export class FlagboxDTO {
  @IsString()
  @IsNotEmpty()
  @Length(7)
  objectivePointDescription: string;
  @IsNumber()
  objectivePointMultiplier: number;
}

export class FlagboxEventDTO {
  node_id: string;
  owner: number;
  action: number;
  capture: number;
  oP_HistoryTimestamp?: string;
  objective_point?: ObjectivePointEntity;
}

export class GameGroupDTO {
  @IsString()
  @Length(3, 31)
  name: string;
}