Compare commits

...
4 Commits
Author SHA1 Message Date
legonzaur e9d5d8d909 chore : remove class-transformer 2024-12-29 23:47:41 +01:00
legonzaur 49adbdec5b chore : cleanup lobby events 2024-12-29 23:39:06 +01:00
legonzaur 72935ba3f5 feat : frontend word edition 2024-12-29 20:40:02 +01:00
legonzaur fff2abf0a1 chore : remove class-transformer 2024-12-29 19:34:43 +01:00
9 changed files with 63 additions and 59 deletions
+2 -6
View File
@@ -1,20 +1,16 @@
import { Expose, Type } from 'class-transformer';
import { ConceptResponseDTO } from './conceptresponse.dto';
export class ConceptInTurnResponseDTO {
constructor(partial: Partial<ConceptInTurnResponseDTO>) {
Object.assign(this, partial);
this.concept = new ConceptResponseDTO(partial.concept);
}
@Type(() => ConceptResponseDTO)
@Expose()
concept: ConceptResponseDTO;
@Expose()
order: number;
@Expose()
subconcept: number;
@Expose()
markers: number;
}
-4
View File
@@ -1,13 +1,9 @@
import { Expose } from 'class-transformer';
export class ConceptResponseDTO {
constructor(partial: Partial<ConceptResponseDTO>) {
Object.assign(this, partial);
}
@Expose()
id: number;
@Expose()
value: string;
}
+6 -15
View File
@@ -1,4 +1,3 @@
import { Expose, Type } from 'class-transformer';
import { UserResponseDTO } from './userresponse.dto';
import { PlayerResponseDTO } from './playerresponse.dto';
import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto';
@@ -6,31 +5,23 @@ import { ConceptInTurnResponseDTO } from './conceptinturnresponse.dto';
export class GameResponseDTO {
constructor(partial: Partial<GameResponseDTO>) {
Object.assign(this, partial);
this.owner = partial.owner;
this.players = partial.players;
this.currentPlayer = partial.currentPlayer;
this.currentConcepts = partial.currentConcepts;
this.owner = new UserResponseDTO(partial.owner);
this.players = partial.players.map((p) => new PlayerResponseDTO(p));
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
this.currentConcepts = partial.currentConcepts.map(
(c) => new ConceptInTurnResponseDTO(c),
);
}
@Expose()
id: number;
@Type(() => UserResponseDTO)
@Expose()
owner: UserResponseDTO;
@Type(() => PlayerResponseDTO)
@Expose()
players: PlayerResponseDTO[];
@Type(() => PlayerResponseDTO)
@Expose()
currentPlayer: PlayerResponseDTO;
@Expose()
started: boolean;
@Type(() => ConceptInTurnResponseDTO)
@Expose()
currentConcepts: ConceptInTurnResponseDTO[];
}
+1 -5
View File
@@ -1,16 +1,12 @@
import { Expose, Type } from 'class-transformer';
import { UserResponseDTO } from './userresponse.dto';
export class PlayerResponseDTO {
constructor(partial: Partial<PlayerResponseDTO>) {
Object.assign(this, partial);
this.user = partial.user;
this.user = new UserResponseDTO(partial.user);
}
@Type(() => UserResponseDTO)
@Expose()
user: UserResponseDTO;
@Expose()
score: number;
}
-6
View File
@@ -1,16 +1,10 @@
import { Expose } from 'class-transformer';
export class UserResponseDTO {
constructor(partial: Partial<UserResponseDTO>) {
Object.assign(this, partial);
this.id = partial.id;
}
@Expose()
id: string;
@Expose()
username: string;
@Expose()
avatar: string;
}
+7 -7
View File
@@ -1,18 +1,18 @@
import { Expose } from 'class-transformer';
export class WordResponseDTO {
constructor(partial: Partial<WordResponseDTO>) {
Object.assign(this, partial);
if (partial.id) this.id = partial.id;
if (partial.value) this.value = partial.value;
if (partial.ownerId) this.ownerId = partial.ownerId;
if (partial.enabled) this.enabled = partial.enabled;
}
@Expose()
id: number;
@Expose()
value: string;
@Expose()
ownerId: string;
@Expose()
enabled: boolean;
loading?: boolean = false;
}
+20
View File
@@ -0,0 +1,20 @@
import { PlayerResponseDTO } from './dto/playerresponse.dto';
export class GameStartEvent {
type = 'start';
}
export class GameDeleteEvent {
type = 'delete';
}
export class GameJoinEvent {
type = 'joingame';
constructor(public player: PlayerResponseDTO) {}
}
export class GameLeaveEvent {
type = 'leavegame';
gameId?: number;
constructor(public player: PlayerResponseDTO) {}
}
+22 -11
View File
@@ -1,23 +1,34 @@
import { GameResponseDTO } from './dto/gameresponse.dto';
import { PlayerResponseDTO } from './dto/playerresponse.dto';
export class GameCreateEvent extends GameResponseDTO {
export class LobbyCreateEvent {
type = 'create';
constructor(public game: GameResponseDTO) {}
}
export class GameDeleteEvent {
type = 'delete';
constructor(public id?: number) { }
export class LobbyStartEvent {
type = 'start';
constructor(public game: GameResponseDTO) {}
}
export class GameJoinEvent {
export class LobbyDeleteEvent {
type = 'delete';
constructor(public id: number) {}
}
export class LobbyJoinEvent {
type = 'joingame';
constructor(
public player: PlayerResponseDTO,
public game: GameResponseDTO,
) {}
}
export class LobbyLeaveEvent {
type = 'leavegame';
gameId?: number;
constructor(
public player: PlayerResponseDTO,
game?: Partial<GameResponseDTO>,
) {
if (game && game.id) {
this.gameId = game.id;
}
}
public game: GameResponseDTO,
) {}
}
+5 -5
View File
@@ -2,25 +2,25 @@ import { WordResponseDTO } from './dto/wordresponse.dto';
export class WordCreateEvent {
type = 'create';
constructor(public word: WordResponseDTO) { }
constructor(public word: WordResponseDTO) {}
}
export class WordEditEvent {
type = 'edit';
constructor(public word: WordResponseDTO) { }
constructor(public word: WordResponseDTO) {}
}
export class WordDeleteEvent {
type = 'delete';
constructor(public id: number) { }
constructor(public id: number) {}
}
export class WordEnableEvent {
type = 'enable';
constructor(public id: number) { }
constructor(public id: number) {}
}
export class WordDisableEvent {
type = 'disable';
constructor(public id: number) { }
constructor(public id: number) {}
}