chore : working on game

This commit is contained in:
2024-12-30 00:39:14 +01:00
parent 37db0a0cdb
commit cfafcfaddf
5 changed files with 8 additions and 6 deletions
+1 -1
Submodule events updated: e9d5d8d909...cdddb9a073
+1 -1
View File
@@ -23,5 +23,5 @@ export class Player {
game: Game; game: Game;
@Column({ default: 0 }) @Column({ default: 0 })
score: number; score: number = 0;
} }
+4 -2
View File
@@ -28,10 +28,13 @@ export class LobbyService {
const createdGame = this.gameRepository.create(); const createdGame = this.gameRepository.create();
createdGame.owner = owner; createdGame.owner = owner;
createdGame.seed = randomUUID(); createdGame.seed = randomUUID();
await this.gameRepository.save(createdGame); await this.gameRepository.save(createdGame);
await this.joinGame(createdGame, owner);
const g = new GameResponseDTO(createdGame); const g = new GameResponseDTO(createdGame);
this.eventEmitter.emit('sse.lobby', new LobbyCreateEvent(g)); this.eventEmitter.emit('sse.lobby', new LobbyCreateEvent(g));
await this.joinGame(createdGame, owner);
return createdGame; return createdGame;
} }
@@ -39,7 +42,6 @@ export class LobbyService {
const player = this.playerRepository.create(); const player = this.playerRepository.create();
player.user = user; player.user = user;
player.game = game; player.game = game;
this.eventEmitter.emit('sse.lobby', new LobbyJoinEvent(player, game)); this.eventEmitter.emit('sse.lobby', new LobbyJoinEvent(player, game));
this.eventEmitter.emit('sse.game.' + game.id, new GameJoinEvent(player)); this.eventEmitter.emit('sse.game.' + game.id, new GameJoinEvent(player));
await this.playerRepository.save(player); await this.playerRepository.save(player);
+1 -1
View File
@@ -1,4 +1,4 @@
import { NestFactory, Reflector } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import * as session from 'express-session'; import * as session from 'express-session';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
+1 -1
View File
@@ -1,7 +1,7 @@
import { User } from '../users/entities/user.entity'; import { User } from '../users/entities/user.entity';
declare module 'express-session' { declare module 'express-session' {
interface SessionData { interface SessionData {
user: User; user?: User;
tokenData: { tokenData: {
access_token: string; access_token: string;
token_type: string; token_type: string;