Skip to content
Snippets Groups Projects
game.dto.ts 1.49 KiB
Newer Older
import {
  IsNotEmpty,
Samuli Virtapohja's avatar
Samuli Virtapohja committed
  IsString,
Samuli Virtapohja's avatar
Samuli Virtapohja committed
  IsDateString,
L4168's avatar
L4168 committed
  IsNumber,
L4168's avatar
L4168 committed
  Validate,
} from 'class-validator';
Samuli Virtapohja's avatar
Samuli Virtapohja committed
import { ObjectivePointEntity } from './game.entity';
L4168's avatar
L4168 committed
import { CenterJSON } from '../shared/custom-validation';

export class GameDTO {
  @IsString()
  @IsNotEmpty()
Samuli Virtapohja's avatar
Samuli Virtapohja committed
  @Length(3, 30)
  name: string;
  @IsNotEmpty()
  @Length(1, 255)
  desc: string;
L4168's avatar
L4168 committed
  @IsNotEmpty()
L4168's avatar
L4168 committed
  @Validate(CenterJSON)
  center: JSON;
  map?: JSON;
L4168's avatar
L4168 committed
  nodesettings?: JSON;
  @IsDateString()
  @IsNotEmpty()
  startdate: string;
  @IsDateString()
  @IsNotEmpty()
  enddate: string;
Samuli Virtapohja's avatar
Samuli Virtapohja committed
  factions?: FactionDTO[];
L4168's avatar
L4168 committed
  objective_points?: FlagboxDTO[];
L4168's avatar
L4168 committed
export class newGameDTO {
  @IsString()
  @IsNotEmpty()
  @Length(3, 30)
  name: string;
  @IsString()
  @IsNotEmpty()
  @Length(1, 255)
  desc: string;
  @IsNotEmpty()
L4168's avatar
L4168 committed
  @Validate(CenterJSON)
L4168's avatar
L4168 committed
  center: JSON;
  @IsDateString()
  @IsNotEmpty()
  startdate: string;
  @IsDateString()
  @IsNotEmpty()
  enddate: string;
}

export class FactionDTO {
  @IsString()
  @IsNotEmpty()
  @Length(2, 15)
Samuli Virtapohja's avatar
Samuli Virtapohja committed
  factionName: string;
  factionPassword: string;
L4168's avatar
L4168 committed
  multiplier?: number;
  game: GameDTO;
}
L4168's avatar
L4168 committed
export class FlagboxDTO {
  @IsString()
  @IsNotEmpty()
  @Length(7)
  objectivePointDescription: string;
  @IsNumber()
  objectivePointMultiplier: number;
}

export class FlagboxEventDTO {
  node_id: string;
  owner: number;
  action: number;
  capture: number;
L4168's avatar
L4168 committed
  oP_HistoryTimestamp?: string;
  objective_point?: ObjectivePointEntity;
L4168's avatar
L4168 committed
}

export class GameGroupDTO {
  @IsString()
  @Length(3, 31)
  name: string;
L4168's avatar
L4168 committed
}