diff --git a/dto/conceptresponse.dto.ts b/dto/conceptresponse.dto.ts index d200479..78b9b75 100644 --- a/dto/conceptresponse.dto.ts +++ b/dto/conceptresponse.dto.ts @@ -5,6 +5,5 @@ export class ConceptResponseDTO { } id: number; - value: string; } diff --git a/dto/gameresponse.dto.ts b/dto/gameresponse.dto.ts index 38748e3..626a3a2 100644 --- a/dto/gameresponse.dto.ts +++ b/dto/gameresponse.dto.ts @@ -1,13 +1,16 @@ import { UserResponseDTO } from './userresponse.dto'; import { PlayerResponseDTO } from './playerresponse.dto'; import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto'; +import { MessageResponseDTO } from './messageresponse.dto'; export class GameResponseDTO { constructor(partial: Partial) { this.id = partial.id; this.started = partial.started; this.ownerId = partial.ownerId; - // this.owner = new UserResponseDTO(partial.owner); + if (partial.messages) { + this.messages = partial.messages.map((m) => new MessageResponseDTO(m)); + } if (partial.players) { this.players = partial.players.map((p) => new PlayerResponseDTO(p)); } @@ -25,7 +28,7 @@ export class GameResponseDTO { id: number; - ownerId: number; + ownerId: string; players: PlayerResponseDTO[] = []; @@ -34,4 +37,6 @@ export class GameResponseDTO { started: boolean; currentConcepts: ConceptInTurnResponseDTO[] = []; + + messages: MessageResponseDTO[] = []; } diff --git a/dto/messageresponse.dto.ts b/dto/messageresponse.dto.ts new file mode 100644 index 0000000..7581b1e --- /dev/null +++ b/dto/messageresponse.dto.ts @@ -0,0 +1,11 @@ +export class MessageResponseDTO { + constructor(partial: Partial) { + this.id = partial.id; + this.value = partial.value; + this.authorId = partial.authorId; + } + + id: number; + value: string; + authorId: number; +} diff --git a/game.events.ts b/game.events.ts index e363d63..18aacde 100644 --- a/game.events.ts +++ b/game.events.ts @@ -20,8 +20,16 @@ export class GameJoinEvent { export class GameLeaveEvent { type = 'leavegame'; - gameId?: number; constructor(public player: PlayerResponseDTO) { this.player = new PlayerResponseDTO(player); } } + +export class GameMessageEvent { + type = 'message'; + constructor( + public gameId: number, + public authorId: number, + public message: string, + ) {} +}