Suite du jeu et toujours pas fin

This commit is contained in:
batche
2022-12-19 21:37:58 +01:00
parent dbd95089a8
commit 8a11d9c591
3 changed files with 50 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ import { User } from 'src/users/entities/user.entity';
import { UsersService } from 'src/users/users.service';
import { GrantTicketDto } from './dto/grantTicket.dto';
import { ValidateTicketDto } from './dto/validateTicket.dto';
import { TokenGame } from './entity/tokenGame.entity';
import { GameService } from './game.service';
@Controller('game')
@@ -25,13 +26,13 @@ export class GameController {
return this.gameService.generateToken(user, grantTicketDto);
}
@Get('requested')
@Post('requested')
@UseGuards(AuthenticateGuard)
@UseGuards(TwoFactorGuard)
async requestIfAnotherUserHasRespondToquestForGame(@Req() req, @Body('playerTwoUsername') body)
async requestIfAnotherUserHasRespondToquestForGame(@Req() req, @Body('token') token)
{
const user : User = req.user;
return this.gameService.requestIfAnotherUserHasRespondToquestForGame(user, body);
return this.gameService.requestIfAnotherUserHasRespondToquestForGame(user, token);
}

View File

@@ -173,7 +173,7 @@ export class GameService {
if (user.status === "In Game")
return new HttpException("You can't do that.", HttpStatus.BAD_REQUEST)
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokenGame')
.andWhere('tokenGame.token = :token', {token : token})
.where('tokenGame.token = :token', {token : token})
.andWhere('tokenGame.isSecondUserAcceptedRequest = :isSecondUserAcceptedRequest', {isSecondUserAcceptedRequest : true})
.getOne();
if (tokenGame && tokenGame.isSecondUserAcceptedRequest === true)