feat: game creation and login

This commit is contained in:
2024-12-28 17:38:25 +01:00
parent a3dc01171a
commit c7c778a55b
29 changed files with 1735 additions and 1104 deletions
+4 -2
View File
@@ -12,12 +12,13 @@ import {
import { LobbyService } from '../services/lobby.service';
import { AuthGuard } from '../guards/auth.guard';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { Game } from '../schemas/game.schema';
import { Game } from '../entities/game.entity';
import { GamePipe, GameStartedPipe } from '../pipe/game.pipe';
import { Observable, fromEvent, map } from 'rxjs';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { GameService } from '../services/games.service';
import { ConfigService } from '@nestjs/config';
@ApiTags('game')
@Controller('games/:id')
@@ -26,6 +27,7 @@ export class GamesController {
private readonly lobbyService: LobbyService,
private readonly gameService: GameService,
private eventEmitter: EventEmitter2,
private configService: ConfigService,
) {}
@Post('/start')
@@ -51,7 +53,7 @@ export class GamesController {
if (game.started) {
throw new HttpException('Game already started', HttpStatus.BAD_REQUEST);
}
if (game.players.length < 2 && !process.env.DEV_MODE) {
if (game.players.length < 2 && !this.configService.get('DEV_MODE')) {
throw new HttpException(
'Not enough teams to start the game',
HttpStatus.BAD_REQUEST,