diff --git a/src/game/game.dto.ts b/src/game/game.dto.ts index 4b1fa9b343163c7ec4c9561b55238b1e12da01c5..e4f12e3049dc978dcb5aecff2c20aabde9bb08a2 100644 --- a/src/game/game.dto.ts +++ b/src/game/game.dto.ts @@ -14,7 +14,7 @@ import { import { ObjectivePointEntity } from './game.entity'; import { CenterJSON } from '../shared/custom-validation'; import { FactionDTO } from '../faction/faction.dto'; -import { CenterDTO } from './game.json.dto'; +import { CenterDTO, NodeSettingsDTO } from './game.json.dto'; import { Type } from 'class-transformer'; export class GameDTO { @@ -25,14 +25,15 @@ export class GameDTO { @IsNotEmpty() @Length(1, 255) desc: string; - @IsNotEmpty() @ValidateNested() @Type(() => CenterDTO) center: CenterDTO; @Allow() - map?: JSON; + @ValidateNested() + @Type(() => NodeSettingsDTO) + nodesettings?: NodeSettingsDTO; @Allow() - nodesettings?: JSON; + map?: JSON; @IsDateString() @IsNotEmpty() startdate: string; diff --git a/src/game/game.entity.ts b/src/game/game.entity.ts index 030e81d3960bcb536b419e8a9915d11daa45b744..5f019e83c0b3af08bd423809b79ec5039850bbd2 100644 --- a/src/game/game.entity.ts +++ b/src/game/game.entity.ts @@ -14,7 +14,7 @@ import { PersonEntity } from '../user/user.entity'; import { GameGroupEntity } from '../faction/faction.entity'; import { FactionEntity } from '../faction/faction.entity'; import { TaskEntity } from '../task/task.entity'; -import { CenterDTO } from './game.json.dto'; +import { CenterDTO, NodeSettingsDTO } from './game.json.dto'; // table that stores all created games @Entity('Game') @@ -24,7 +24,7 @@ export class GameEntity { @Column('text') desc: string; @Column('json') center: CenterDTO; @Column({ type: 'json', nullable: true }) map: JSON; - @Column({ type: 'json', nullable: true }) nodesettings?: JSON; + @Column({ type: 'json', nullable: true }) nodesettings?: NodeSettingsDTO; @Column('timestamp') startdate: Timestamp; @Column('timestamp') enddate: Timestamp; diff --git a/src/game/game.json-nested.dto.ts b/src/game/game.json-nested.dto.ts new file mode 100644 index 0000000000000000000000000000000000000000..df67071f089caf3670e46188f92959cfa4e349ad --- /dev/null +++ b/src/game/game.json-nested.dto.ts @@ -0,0 +1,16 @@ +import { IsNumber } from 'class-validator'; + +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; +} diff --git a/src/game/game.json.dto.ts b/src/game/game.json.dto.ts index 31bb4816f968a396202cb4b16728c601dbe1b8bd..5b9484aaa3334d6d564398a96c7e2747f86aab84 100644 --- a/src/game/game.json.dto.ts +++ b/src/game/game.json.dto.ts @@ -1,5 +1,6 @@ -import { GameDTO } from './game.dto'; -import { IsNumber } from 'class-validator'; +import { IsNumber, ValidateNested } from 'class-validator'; +import { NodeCoreSettingsDTO } from './game.json-nested.dto'; +import { Type } from 'class-transformer'; export class CenterDTO { @IsNumber() @@ -7,3 +8,9 @@ export class CenterDTO { @IsNumber() lng: number; } + +export class NodeSettingsDTO { + @ValidateNested() + @Type(() => NodeCoreSettingsDTO) + node_settings: NodeCoreSettingsDTO; +}