Feat : add messages

This commit is contained in:
2024-12-30 17:41:17 +01:00
parent 63f8cd45af
commit 813d942638
4 changed files with 27 additions and 4 deletions
-1
View File
@@ -5,6 +5,5 @@ export class ConceptResponseDTO {
}
id: number;
value: string;
}
+7 -2
View File
@@ -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<GameResponseDTO>) {
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[] = [];
}
+11
View File
@@ -0,0 +1,11 @@
export class MessageResponseDTO {
constructor(partial: Partial<MessageResponseDTO>) {
this.id = partial.id;
this.value = partial.value;
this.authorId = partial.authorId;
}
id: number;
value: string;
authorId: number;
}
+9 -1
View File
@@ -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,
) {}
}