Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
game.dto.ts 1.83 KiB
import {
  IsNotEmpty,
  IsString,
  Length,
  IsDateString,
  IsNumber,
  Validate,
  Min,
  Max,
  ValidateNested,
  Allow,
} from 'class-validator';

import { ObjectivePointEntity } from './game.entity';
import { CenterJSON } from '../shared/custom-validation';
import { FactionDTO } from '../faction/faction.dto';
import { CenterDTO } from './game.json.dto';
import { Type } from 'class-transformer';

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

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

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

export class FlagboxEventDTO {
  @IsString()
  @IsNotEmpty()
  @Length(7)
  node_id: string;
  @IsNumber()
  @Min(0)
  @Max(3)
  owner: number; // owner = 0, => first entry in faction db, owner = 1, => second entry etc
  @IsNumber()
  @Min(0)
  @Max(3)
  action: number; // 0=no capture ongoing, 1=captured, 2=capture ongoing
  @IsNumber()
  @Min(0)
  @Max(3)
  capture: number; // which faction is capturing, same logic as in owner with numbers
  oP_HistoryTimestamp?: string;
  objective_point?: ObjectivePointEntity;
}