Files
events/dto/gameresponse.dto.ts
T
2024-12-30 00:39:06 +01:00

37 lines
958 B
TypeScript

import { UserResponseDTO } from './userresponse.dto';
import { PlayerResponseDTO } from './playerresponse.dto';
import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto';
export class GameResponseDTO {
constructor(partial: Partial<GameResponseDTO>) {
this.id = partial.id;
this.started = partial.started;
this.owner = new UserResponseDTO(partial.owner);
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;
owner: UserResponseDTO;
players: PlayerResponseDTO[] = [];
currentPlayer?: PlayerResponseDTO;
started: boolean;
currentConcepts: ConceptInTurnResponseDTO[] = [];
}