Compare commits

...
10 Commits
Author SHA1 Message Date
legonzaur fc3f0e1677 add GameEndTurnEvent 2024-12-30 19:08:23 +01:00
legonzaur c1a22098f7 add player hasGuessed 2024-12-30 18:36:56 +01:00
legonzaur 22656ba608 add delete message 2024-12-30 18:13:12 +01:00
legonzaur 924806e4c8 fix : set message event to use MessageResponseDTO 2024-12-30 17:54:13 +01:00
legonzaur 47ed1ba851 fix : set message event to use messageResponseDTO 2024-12-30 17:53:31 +01:00
legonzaur 27b1044832 update messageResponse author id 2024-12-30 17:45:05 +01:00
legonzaur 813d942638 Feat : add messages 2024-12-30 17:41:17 +01:00
legonzaur 63f8cd45af set userid to strng 2024-12-30 12:06:49 +01:00
legonzaur e872eeea91 feat : send only user ids 2024-12-30 12:04:53 +01:00
legonzaur 735e47cdbe feat: add gameStartEvent 2024-12-30 11:14:47 +01:00
5 changed files with 49 additions and 9 deletions
-1
View File
@@ -5,6 +5,5 @@ export class ConceptResponseDTO {
}
id: number;
value: string;
}
+8 -2
View File
@@ -1,12 +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.owner = new UserResponseDTO(partial.owner);
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));
}
@@ -24,7 +28,7 @@ export class GameResponseDTO {
id: number;
owner: UserResponseDTO;
ownerId: string;
players: PlayerResponseDTO[] = [];
@@ -33,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;
if (partial.authorId) this.authorId = partial.authorId;
}
id: number;
value: string;
authorId?: string;
}
+7 -5
View File
@@ -1,12 +1,14 @@
import { UserResponseDTO } from './userresponse.dto';
export class PlayerResponseDTO {
constructor(partial: Partial<PlayerResponseDTO>) {
this.score = partial.score;
this.user = new UserResponseDTO(partial.user);
this.userId = partial.userId;
this.id = partial.id;
this.hasGuessed = partial.hasGuessed;
// this.user = new UserResponseDTO(partial.user);
}
user: UserResponseDTO;
id: number;
userId: string;
score: number;
hasGuessed: boolean;
}
+23 -1
View File
@@ -1,7 +1,11 @@
import { MessageResponseDTO } from './dto/messageresponse.dto';
import { PlayerResponseDTO } from './dto/playerresponse.dto';
export class GameStartEvent {
type = 'start';
constructor(public currentPlayer: PlayerResponseDTO) {
this.currentPlayer = new PlayerResponseDTO(currentPlayer);
}
}
export class GameDeleteEvent {
@@ -17,8 +21,26 @@ 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 message: MessageResponseDTO) {
this.message = new MessageResponseDTO(message);
}
}
export class GameMessageDeleteEvent {
type = 'deleteMessage';
constructor(public messageId: number) {}
}
export class GameEndTurnEvent {
type = 'endTurn';
constructor(public currentPlayer: PlayerResponseDTO) {
this.currentPlayer = new PlayerResponseDTO(currentPlayer);
}
}