Files
webapp-dto/dto/gameresponse.dto.ts
T
2024-12-30 17:41:17 +01:00

43 lines
1.1 KiB
TypeScript

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;
if (partial.messages) {
this.messages = partial.messages.map((m) => new MessageResponseDTO(m));
}
if (partial.players) {
this.players = partial.players.map((p) => new PlayerResponseDTO(p));
}
if (partial.currentConcepts) {
this.currentConcepts = partial.currentConcepts.map(
(c) => new ConceptInTurnResponseDTO(c),
);
}
if (partial.currentPlayer) {
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
}
}
id: number;
ownerId: string;
players: PlayerResponseDTO[] = [];
currentPlayer?: PlayerResponseDTO;
started: boolean;
currentConcepts: ConceptInTurnResponseDTO[] = [];
messages: MessageResponseDTO[] = [];
}