Compare commits
18
Commits
72935ba3f5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccd11f29a1 | ||
|
|
913c82994a | ||
|
|
24c39d23d6 | ||
|
|
a99853f417 | ||
|
|
1473c5c132 | ||
|
|
fc3f0e1677 | ||
|
|
c1a22098f7 | ||
|
|
22656ba608 | ||
|
|
924806e4c8 | ||
|
|
47ed1ba851 | ||
|
|
27b1044832 | ||
|
|
813d942638 | ||
|
|
63f8cd45af | ||
|
|
e872eeea91 | ||
|
|
735e47cdbe | ||
|
|
cdddb9a073 | ||
|
|
e9d5d8d909 | ||
|
|
49adbdec5b |
@@ -1,20 +0,0 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
import { ConceptResponseDTO } from './conceptresponse.dto';
|
||||
|
||||
export class ConceptInTurnResponseDTO {
|
||||
constructor(partial: Partial<ConceptInTurnResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
@Type(() => ConceptResponseDTO)
|
||||
@Expose()
|
||||
concept: ConceptResponseDTO;
|
||||
|
||||
@Expose()
|
||||
order: number;
|
||||
|
||||
@Expose()
|
||||
subconcept: number;
|
||||
|
||||
@Expose()
|
||||
markers: number;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Expose } from 'class-transformer';
|
||||
|
||||
export class ConceptResponseDTO {
|
||||
constructor(partial: Partial<ConceptResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
}
|
||||
|
||||
@Expose()
|
||||
id: number;
|
||||
|
||||
@Expose()
|
||||
value: string;
|
||||
}
|
||||
+18
-22
@@ -1,36 +1,32 @@
|
||||
import { Expose, Type } from 'class-transformer';
|
||||
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>) {
|
||||
Object.assign(this, partial);
|
||||
this.owner = partial.owner;
|
||||
this.players = partial.players;
|
||||
this.currentPlayer = partial.currentPlayer;
|
||||
this.currentConcepts = partial.currentConcepts;
|
||||
this.id = partial.id;
|
||||
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));
|
||||
}
|
||||
|
||||
if (partial.currentPlayer) {
|
||||
this.currentPlayer = new PlayerResponseDTO(partial.currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Expose()
|
||||
id: number;
|
||||
|
||||
@Type(() => UserResponseDTO)
|
||||
@Expose()
|
||||
owner: UserResponseDTO;
|
||||
ownerId: string;
|
||||
|
||||
@Type(() => PlayerResponseDTO)
|
||||
@Expose()
|
||||
players: PlayerResponseDTO[];
|
||||
players: PlayerResponseDTO[] = [];
|
||||
|
||||
@Type(() => PlayerResponseDTO)
|
||||
@Expose()
|
||||
currentPlayer: PlayerResponseDTO;
|
||||
currentPlayer?: PlayerResponseDTO;
|
||||
|
||||
@Expose()
|
||||
started: boolean;
|
||||
|
||||
@Type(() => ConceptInTurnResponseDTO)
|
||||
@Expose()
|
||||
currentConcepts: ConceptInTurnResponseDTO[];
|
||||
messages: MessageResponseDTO[] = [];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
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.score = partial.score;
|
||||
this.userId = partial.userId;
|
||||
this.id = partial.id;
|
||||
this.hasGuessed = partial.hasGuessed;
|
||||
// this.user = new UserResponseDTO(partial.user);
|
||||
}
|
||||
|
||||
@Type(() => UserResponseDTO)
|
||||
@Expose()
|
||||
user: UserResponseDTO;
|
||||
|
||||
@Expose()
|
||||
id: number;
|
||||
userId: string;
|
||||
score: number;
|
||||
hasGuessed: boolean;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
|
||||
|
||||
export class UserResponseDTO {
|
||||
constructor(partial: Partial<UserResponseDTO>) {
|
||||
Object.assign(this, partial);
|
||||
|
||||
constructor(partial: UserResponseDTO) {
|
||||
this.id = partial.id;
|
||||
this.username = partial.username;
|
||||
this.avatar = partial.avatar;
|
||||
}
|
||||
id: string;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
export class WordResponseDTO {
|
||||
constructor(partial: Partial<WordResponseDTO>) {
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
id: number;
|
||||
@@ -14,9 +14,5 @@ export class WordResponseDTO {
|
||||
|
||||
enabled: boolean;
|
||||
|
||||
loading?: boolean = false
|
||||
|
||||
toJSON() {
|
||||
return { ...this } // here I make a POJO's copy of the class instance
|
||||
}
|
||||
loading?: boolean = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import { MessageResponseDTO } from "./dto/messageresponse.dto";
|
||||
import { PlayerResponseDTO } from "./dto/playerresponse.dto";
|
||||
import type { ConceptEvent } from "./events";
|
||||
|
||||
export class GameStartEvent implements ConceptEvent {
|
||||
type = "start";
|
||||
constructor(public currentPlayer: PlayerResponseDTO) {
|
||||
this.currentPlayer = new PlayerResponseDTO(currentPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
export class GameDeleteEvent implements ConceptEvent {
|
||||
type = "delete";
|
||||
}
|
||||
|
||||
export class GameJoinEvent implements ConceptEvent {
|
||||
type = "joingame";
|
||||
constructor(public player: PlayerResponseDTO) {
|
||||
this.player = new PlayerResponseDTO(player);
|
||||
}
|
||||
}
|
||||
|
||||
export class GameLeaveEvent implements ConceptEvent {
|
||||
type = "leavegame";
|
||||
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);
|
||||
}
|
||||
}
|
||||
+36
-13
@@ -1,23 +1,46 @@
|
||||
import { GameResponseDTO } from './dto/gameresponse.dto';
|
||||
import { PlayerResponseDTO } from './dto/playerresponse.dto';
|
||||
import { GameResponseDTO } from "./dto/gameresponse.dto";
|
||||
import { PlayerResponseDTO } from "./dto/playerresponse.dto";
|
||||
import type { ConceptEvent } from "./events";
|
||||
|
||||
export class GameCreateEvent extends GameResponseDTO {
|
||||
type = 'create';
|
||||
export class LobbyCreateEvent implements ConceptEvent {
|
||||
type = "create";
|
||||
game: GameResponseDTO;
|
||||
constructor(game: GameResponseDTO) {
|
||||
this.game = new GameResponseDTO(game);
|
||||
}
|
||||
}
|
||||
|
||||
export class GameDeleteEvent {
|
||||
type = 'delete';
|
||||
constructor(public id?: number) { }
|
||||
export class LobbyStartEvent implements ConceptEvent {
|
||||
type = "start";
|
||||
constructor(public game: GameResponseDTO) {
|
||||
this.game = new GameResponseDTO(game);
|
||||
}
|
||||
}
|
||||
export class GameJoinEvent {
|
||||
type = 'joingame';
|
||||
|
||||
export class LobbyDeleteEvent implements ConceptEvent {
|
||||
type = "delete";
|
||||
constructor(public id: number) {}
|
||||
}
|
||||
|
||||
export class LobbyJoinEvent implements ConceptEvent {
|
||||
type = "joingame";
|
||||
constructor(
|
||||
public player: PlayerResponseDTO,
|
||||
public game: GameResponseDTO,
|
||||
) {
|
||||
this.player = new PlayerResponseDTO(player);
|
||||
this.game = new GameResponseDTO(game);
|
||||
}
|
||||
}
|
||||
|
||||
export class LobbyLeaveEvent implements ConceptEvent {
|
||||
type = "leavegame";
|
||||
gameId?: number;
|
||||
constructor(
|
||||
public player: PlayerResponseDTO,
|
||||
game?: Partial<GameResponseDTO>,
|
||||
public game: GameResponseDTO,
|
||||
) {
|
||||
if (game && game.id) {
|
||||
this.gameId = game.id;
|
||||
}
|
||||
this.player = new PlayerResponseDTO(player);
|
||||
this.game = new GameResponseDTO(game);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-16
@@ -1,26 +1,31 @@
|
||||
import { WordResponseDTO } from './dto/wordresponse.dto';
|
||||
import { WordResponseDTO } from "./dto/wordresponse.dto";
|
||||
import type { ConceptEvent } from "./events";
|
||||
|
||||
export class WordCreateEvent {
|
||||
type = 'create';
|
||||
constructor(public word: WordResponseDTO) { }
|
||||
export class WordCreateEvent implements ConceptEvent {
|
||||
type = "create";
|
||||
constructor(public word: WordResponseDTO) {
|
||||
this.word = new WordResponseDTO(word);
|
||||
}
|
||||
}
|
||||
|
||||
export class WordEditEvent {
|
||||
type = 'edit';
|
||||
constructor(public word: WordResponseDTO) { }
|
||||
export class WordEditEvent implements ConceptEvent {
|
||||
type = "edit";
|
||||
constructor(public word: WordResponseDTO) {
|
||||
this.word = new WordResponseDTO(word);
|
||||
}
|
||||
}
|
||||
|
||||
export class WordDeleteEvent {
|
||||
type = 'delete';
|
||||
constructor(public id: number) { }
|
||||
export class WordDeleteEvent implements ConceptEvent {
|
||||
type = "delete";
|
||||
constructor(public id: number) {}
|
||||
}
|
||||
|
||||
export class WordEnableEvent {
|
||||
type = 'enable';
|
||||
constructor(public id: number) { }
|
||||
export class WordEnableEvent implements ConceptEvent {
|
||||
type = "enable";
|
||||
constructor(public id: number) {}
|
||||
}
|
||||
|
||||
export class WordDisableEvent {
|
||||
type = 'disable';
|
||||
constructor(public id: number) { }
|
||||
export class WordDisableEvent implements ConceptEvent {
|
||||
type = "disable";
|
||||
constructor(public id: number) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user