|
|
|
## game.dto.ts
|
|
|
|
|
|
|
|
### newGameDTO
|
|
|
|
### NewGameDTO
|
|
|
|
|
|
|
|
`ValidateNested()` and `Type(() => DTO)` is needed for ValidationPipe to validate nested DTOs.
|
|
|
|
|
|
|
|
? in the key's name means, that the key-value pair is optional.
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
{
|
|
|
|
export class newGameDTO {
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
| ... | ... | @@ -27,5 +30,118 @@ |
|
|
|
@Allow()
|
|
|
|
map?: JSON;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### CenterDTO
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
export class CenterDTO {
|
|
|
|
@IsNumber()
|
|
|
|
lat: number;
|
|
|
|
@IsNumber()
|
|
|
|
lng: number;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### GameDTO
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
export class GameDTO {
|
|
|
|
@IsOptional()
|
|
|
|
id: string;
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
@Length(3, 30)
|
|
|
|
name: string;
|
|
|
|
@IsNotEmpty()
|
|
|
|
@Length(1, 255)
|
|
|
|
desc: string;
|
|
|
|
@ValidateNested()
|
|
|
|
@Type(() => CenterDTO)
|
|
|
|
center: CenterDTO;
|
|
|
|
@Allow()
|
|
|
|
@ValidateNested()
|
|
|
|
@Type(() => NodeSettingsDTO)
|
|
|
|
nodesettings?: NodeSettingsDTO;
|
|
|
|
@Allow()
|
|
|
|
map?: JSON;
|
|
|
|
@IsDateString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
startdate: string;
|
|
|
|
@IsDateString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
enddate: string;
|
|
|
|
@ValidateNested()
|
|
|
|
@Type(() => FactionDTO)
|
|
|
|
factions?: FactionDTO[];
|
|
|
|
@ValidateNested()
|
|
|
|
@Type(() => FlagboxDTO)
|
|
|
|
objective_points?: FlagboxDTO[];
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### NodeSettingsDTO
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
export class NodeSettingsDTO {
|
|
|
|
@ValidateNested()
|
|
|
|
@Type(() => NodeCoreSettingsDTO)
|
|
|
|
node_settings: NodeCoreSettingsDTO;
|
|
|
|
}
|
|
|
|
export class NodeCoreSettingsDTO {
|
|
|
|
@IsNumber()
|
|
|
|
capture_time: number;
|
|
|
|
@IsNumber()
|
|
|
|
confirmation_time: number;
|
|
|
|
@IsNumber()
|
|
|
|
owner: number;
|
|
|
|
@IsNumber()
|
|
|
|
capture: number;
|
|
|
|
@IsNumber()
|
|
|
|
buttons_available: number;
|
|
|
|
@IsNumber()
|
|
|
|
heartbeat_interval: number;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### FactionDTO
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
export class FactionDTO {
|
|
|
|
@IsOptional()
|
|
|
|
@IsUUID("4")
|
|
|
|
factionId?: string;
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
@Length(2, 31)
|
|
|
|
factionName: string;
|
|
|
|
@IsHexColor()
|
|
|
|
colour: string;
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
@Length(3, 15)
|
|
|
|
factionPassword: string;
|
|
|
|
@IsNumber()
|
|
|
|
@Min(1)
|
|
|
|
@Max(3)
|
|
|
|
multiplier?: number;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### FlagboxDTO
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
export class FlagboxDTO {
|
|
|
|
@IsOptional()
|
|
|
|
@IsUUID("4")
|
|
|
|
objectivePointId: string;
|
|
|
|
@IsString()
|
|
|
|
@IsNotEmpty()
|
|
|
|
@Length(7, 7)
|
|
|
|
objectivePointDescription: string;
|
|
|
|
@IsNumber()
|
|
|
|
objectivePointMultiplier: number;
|
|
|
|
@IsOptional()
|
|
|
|
data: JSON;
|
|
|
|
}
|
|
|
|
``` |