Template
Feat : add messages
This commit is contained in:
@@ -5,6 +5,5 @@ export class ConceptResponseDTO {
|
||||
}
|
||||
|
||||
id: number;
|
||||
|
||||
value: string;
|
||||
}
|
||||
|
||||
@@ -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[] = [];
|
||||
}
|
||||
|
||||
@@ -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
@@ -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,
|
||||
) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user