Compare commits

...
16 Commits
Author SHA1 Message Date
legonzaur ccd11f29a1 chore: formatting 2025-05-06 14:36:52 +02:00
legonzaur 913c82994a chore: remove concept 2025-05-06 14:23:53 +02:00
legonzaur 24c39d23d6 chore : eslint 2025-01-13 22:33:38 +01:00
legonzaur a99853f417 feat: add concept type 2025-01-13 22:14:45 +01:00
legonzaur 1473c5c132 feat: concept events 2024-12-31 14:15:38 +01:00
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
legonzaur cdddb9a073 fix : unify dto conversion 2024-12-30 00:39:06 +01:00
10 changed files with 129 additions and 87 deletions
-16
View File
@@ -1,16 +0,0 @@
import { ConceptResponseDTO } from './conceptresponse.dto';
export class ConceptInTurnResponseDTO {
constructor(partial: Partial<ConceptInTurnResponseDTO>) {
Object.assign(this, partial);
this.concept = new ConceptResponseDTO(partial.concept);
}
concept: ConceptResponseDTO;
order: number;
subconcept: number;
markers: number;
}
-9
View File
@@ -1,9 +0,0 @@
export class ConceptResponseDTO {
constructor(partial: Partial<ConceptResponseDTO>) {
Object.assign(this, partial);
}
id: number;
value: string;
}
+16 -11
View File
@@ -1,27 +1,32 @@
import { UserResponseDTO } from './userresponse.dto';
import { PlayerResponseDTO } from './playerresponse.dto'; import { PlayerResponseDTO } from './playerresponse.dto';
import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto'; import { MessageResponseDTO } from './messageresponse.dto';
export class GameResponseDTO { export class GameResponseDTO {
constructor(partial: Partial<GameResponseDTO>) { constructor(partial: Partial<GameResponseDTO>) {
Object.assign(this, partial); this.id = partial.id;
this.owner = new UserResponseDTO(partial.owner); 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)); this.players = partial.players.map((p) => new PlayerResponseDTO(p));
}
if (partial.currentPlayer) {
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer); this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
this.currentConcepts = partial.currentConcepts.map( }
(c) => new ConceptInTurnResponseDTO(c),
);
} }
id: number; id: number;
owner: UserResponseDTO; ownerId: string;
players: PlayerResponseDTO[]; players: PlayerResponseDTO[] = [];
currentPlayer: PlayerResponseDTO; currentPlayer?: PlayerResponseDTO;
started: boolean; 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;
}
+8 -6
View File
@@ -1,12 +1,14 @@
import { UserResponseDTO } from './userresponse.dto';
export class PlayerResponseDTO { export class PlayerResponseDTO {
constructor(partial: Partial<PlayerResponseDTO>) { constructor(partial: Partial<PlayerResponseDTO>) {
Object.assign(this, partial); 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; score: number;
hasGuessed: boolean;
} }
+4 -2
View File
@@ -1,6 +1,8 @@
export class UserResponseDTO { export class UserResponseDTO {
constructor(partial: Partial<UserResponseDTO>) { constructor(partial: UserResponseDTO) {
Object.assign(this, partial); this.id = partial.id;
this.username = partial.username;
this.avatar = partial.avatar;
} }
id: string; id: string;
+3
View File
@@ -0,0 +1,3 @@
export interface ConceptEvent {
type: string;
}
+39 -12
View File
@@ -1,20 +1,47 @@
import { PlayerResponseDTO } from './dto/playerresponse.dto'; import { MessageResponseDTO } from "./dto/messageresponse.dto";
import { PlayerResponseDTO } from "./dto/playerresponse.dto";
import type { ConceptEvent } from "./events";
export class GameStartEvent { export class GameStartEvent implements ConceptEvent {
type = 'start'; type = "start";
constructor(public currentPlayer: PlayerResponseDTO) {
this.currentPlayer = new PlayerResponseDTO(currentPlayer);
}
} }
export class GameDeleteEvent { export class GameDeleteEvent implements ConceptEvent {
type = 'delete'; type = "delete";
} }
export class GameJoinEvent { export class GameJoinEvent implements ConceptEvent {
type = 'joingame'; type = "joingame";
constructor(public player: PlayerResponseDTO) {} constructor(public player: PlayerResponseDTO) {
this.player = new PlayerResponseDTO(player);
}
} }
export class GameLeaveEvent { export class GameLeaveEvent implements ConceptEvent {
type = 'leavegame'; type = "leavegame";
gameId?: number; constructor(public player: PlayerResponseDTO) {
constructor(public player: PlayerResponseDTO) {} this.player = new PlayerResponseDTO(player);
}
}
export class GameMessageEvent implements ConceptEvent {
type = "message";
constructor(public message: MessageResponseDTO) {
this.message = new MessageResponseDTO(message);
}
}
export class GameMessageDeleteEvent implements ConceptEvent {
type = "deleteMessage";
constructor(public messageId: number) {}
}
export class GameEndTurnEvent implements ConceptEvent {
type = "endTurn";
constructor(public currentPlayer: PlayerResponseDTO) {
this.currentPlayer = new PlayerResponseDTO(currentPlayer);
}
} }
+28 -16
View File
@@ -1,34 +1,46 @@
import { GameResponseDTO } from './dto/gameresponse.dto'; import { GameResponseDTO } from "./dto/gameresponse.dto";
import { PlayerResponseDTO } from './dto/playerresponse.dto'; import { PlayerResponseDTO } from "./dto/playerresponse.dto";
import type { ConceptEvent } from "./events";
export class LobbyCreateEvent { export class LobbyCreateEvent implements ConceptEvent {
type = 'create'; type = "create";
constructor(public game: GameResponseDTO) {} game: GameResponseDTO;
constructor(game: GameResponseDTO) {
this.game = new GameResponseDTO(game);
}
} }
export class LobbyStartEvent { export class LobbyStartEvent implements ConceptEvent {
type = 'start'; type = "start";
constructor(public game: GameResponseDTO) {} constructor(public game: GameResponseDTO) {
this.game = new GameResponseDTO(game);
}
} }
export class LobbyDeleteEvent { export class LobbyDeleteEvent implements ConceptEvent {
type = 'delete'; type = "delete";
constructor(public id: number) {} constructor(public id: number) {}
} }
export class LobbyJoinEvent { export class LobbyJoinEvent implements ConceptEvent {
type = 'joingame'; type = "joingame";
constructor( constructor(
public player: PlayerResponseDTO, public player: PlayerResponseDTO,
public game: GameResponseDTO, public game: GameResponseDTO,
) {} ) {
this.player = new PlayerResponseDTO(player);
this.game = new GameResponseDTO(game);
}
} }
export class LobbyLeaveEvent { export class LobbyLeaveEvent implements ConceptEvent {
type = 'leavegame'; type = "leavegame";
gameId?: number; gameId?: number;
constructor( constructor(
public player: PlayerResponseDTO, public player: PlayerResponseDTO,
public game: GameResponseDTO, public game: GameResponseDTO,
) {} ) {
this.player = new PlayerResponseDTO(player);
this.game = new GameResponseDTO(game);
}
} }
+18 -13
View File
@@ -1,26 +1,31 @@
import { WordResponseDTO } from './dto/wordresponse.dto'; import { WordResponseDTO } from "./dto/wordresponse.dto";
import type { ConceptEvent } from "./events";
export class WordCreateEvent { export class WordCreateEvent implements ConceptEvent {
type = 'create'; type = "create";
constructor(public word: WordResponseDTO) {} constructor(public word: WordResponseDTO) {
this.word = new WordResponseDTO(word);
}
} }
export class WordEditEvent { export class WordEditEvent implements ConceptEvent {
type = 'edit'; type = "edit";
constructor(public word: WordResponseDTO) {} constructor(public word: WordResponseDTO) {
this.word = new WordResponseDTO(word);
}
} }
export class WordDeleteEvent { export class WordDeleteEvent implements ConceptEvent {
type = 'delete'; type = "delete";
constructor(public id: number) {} constructor(public id: number) {}
} }
export class WordEnableEvent { export class WordEnableEvent implements ConceptEvent {
type = 'enable'; type = "enable";
constructor(public id: number) {} constructor(public id: number) {}
} }
export class WordDisableEvent { export class WordDisableEvent implements ConceptEvent {
type = 'disable'; type = "disable";
constructor(public id: number) {} constructor(public id: number) {}
} }