Compare commits

..
15 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
10 changed files with 87 additions and 78 deletions
-18
View File
@@ -1,18 +0,0 @@
import { ConceptResponseDTO } from './conceptresponse.dto';
export class ConceptInTurnResponseDTO {
constructor(partial: Partial<ConceptInTurnResponseDTO>) {
this.order = partial.order;
this.subconcept = partial.subconcept;
this.markers = partial.markers;
this.concept = new ConceptResponseDTO(partial.concept);
}
concept: ConceptResponseDTO;
order: number;
subconcept: number;
markers: number;
}
-10
View File
@@ -1,10 +0,0 @@
export class ConceptResponseDTO {
constructor(partial: Partial<ConceptResponseDTO>) {
this.id = partial.id;
this.value = partial.value;
}
id: number;
value: string;
}
+7 -11
View File
@@ -1,22 +1,18 @@
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>) {
this.id = partial.id; this.id = partial.id;
this.started = partial.started; 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) { if (partial.players) {
this.players = partial.players.map((p) => new PlayerResponseDTO(p)); this.players = partial.players.map((p) => new PlayerResponseDTO(p));
} }
if (partial.currentConcepts) {
this.currentConcepts = partial.currentConcepts.map(
(c) => new ConceptInTurnResponseDTO(c),
);
}
if (partial.currentPlayer) { if (partial.currentPlayer) {
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer); this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
} }
@@ -24,7 +20,7 @@ export class GameResponseDTO {
id: number; id: number;
owner: UserResponseDTO; ownerId: string;
players: PlayerResponseDTO[] = []; players: PlayerResponseDTO[] = [];
@@ -32,5 +28,5 @@ export class GameResponseDTO {
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;
}
+7 -5
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>) {
this.score = partial.score; 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;
} }
+1 -1
View File
@@ -1,5 +1,5 @@
export class UserResponseDTO { export class UserResponseDTO {
constructor(partial: Partial<UserResponseDTO>) { constructor(partial: UserResponseDTO) {
this.id = partial.id; this.id = partial.id;
this.username = partial.username; this.username = partial.username;
this.avatar = partial.avatar; this.avatar = partial.avatar;
+3
View File
@@ -0,0 +1,3 @@
export interface ConceptEvent {
type: string;
}
+33 -10
View File
@@ -1,24 +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); 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); 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);
}
}
+13 -12
View File
@@ -1,28 +1,29 @@
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";
game: GameResponseDTO; game: GameResponseDTO;
constructor(game: GameResponseDTO) { constructor(game: GameResponseDTO) {
this.game = new GameResponseDTO(game); 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); 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,
@@ -32,8 +33,8 @@ export class LobbyJoinEvent {
} }
} }
export class LobbyLeaveEvent { export class LobbyLeaveEvent implements ConceptEvent {
type = 'leavegame'; type = "leavegame";
gameId?: number; gameId?: number;
constructor( constructor(
public player: PlayerResponseDTO, public player: PlayerResponseDTO,
+12 -11
View File
@@ -1,30 +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); 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); 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) {}
} }