diff --git a/src/game/game.dto.ts b/src/game/game.dto.ts index 5f70a7d43e1acb68dba89e28e31445ee5c76af3d..a5d43f5d624a7ff690d2a5e6fa6e2db4d45eaed1 100644 --- a/src/game/game.dto.ts +++ b/src/game/game.dto.ts @@ -1,22 +1,26 @@ import { - IsString, - IsDateString, - IsJSON, IsNotEmpty, + IsString, + IsDate, Length, + IsInt, + Min, + Max, IsArray, - Validate, + IsJSON, } from 'class-validator'; -import { ArrayLength } from 'src/shared/array-validation'; +import { Timestamp } from 'typeorm'; export class GameDTO { - // uses class-validator built in validations - // see https://github.com/typestack/class-validator @IsString() @IsNotEmpty() - @Length(2, 31) + @Length(3, 30) name: string; + @IsString() + gameDescription?: string; + + @IsDate() @IsNotEmpty() @Length(1, 255) desc: string; @@ -36,6 +40,14 @@ export class GameDTO { // custom validation for array length (arr>min, arr<max) //@Validate(ArrayLength, [4, 8]) factions?: FactionDTO[]; + + @IsArray() + @IsNotEmpty() + objectivePoint?: ObjectivePointDTO[]; + + @IsJSON() + @IsNotEmpty() + mapCoordinates: JSON; } export class FactionDTO { diff --git a/src/game/game.module.ts b/src/game/game.module.ts index 4b56620b4ba0d4fa3c90b8579b067e8418d5cf60..7df189f348bf12543437ecdd85d892980115c7ae 100644 --- a/src/game/game.module.ts +++ b/src/game/game.module.ts @@ -11,6 +11,6 @@ import { FactionEntity } from './faction.entity'; @Module({ imports: [TypeOrmModule.forFeature([GameEntity, FactionEntity, Game_PersonEntity, PersonEntity, GameGroupEntity])], controllers: [GameController], - providers: [GameService] + providers: [GameService], }) export class GameModule {} diff --git a/src/game/game.service.ts b/src/game/game.service.ts index dd3b7048693fbca844888fbe4251854e97918aca..8dbc824e5d91b2ec9d9e1da54cbdd90a53e1ea96 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -92,6 +92,14 @@ export class GameService { }; } + async deleteGame(id) { + // TODO: Delete factions from Faction table associated with the deleted game + await this.gameRepository.delete({ id }); + return { + message: 'Game deleted', + }; + } + // checks the password, creates an entry in GamePerson table with associated role&faction async createGroup(person, gameId, groupData) { try { diff --git a/src/user/user.entity.ts b/src/user/user.entity.ts index 0d003830f3330cf005632b78b52b94f55559d7dc..6323836fdcaf3fbd91a3be97268e9a659e142b41 100644 --- a/src/user/user.entity.ts +++ b/src/user/user.entity.ts @@ -7,9 +7,9 @@ import { } from 'typeorm'; import * as bcrypt from 'bcryptjs'; import * as jwt from 'jsonwebtoken'; - -import { MapMarkerEntity } from '../mapmarkers/mapmarker.entity'; -import { Game_PersonEntity } from '../game/game.entity'; +import { MapMarkerEntity } from 'src/mapmarkers/mapmarker.entity'; +import {TaskEntity} from '../game/faction.entity' +import {Game_PersonEntity} from '../game/game.entity' @Entity('Person') export class PersonEntity {