problèmes du jeu réglés en grosse partie
This commit is contained in:
@@ -102,6 +102,11 @@ export class GameController {
|
||||
return this.gameService.updateGame(updateGameDto);
|
||||
}
|
||||
|
||||
@Post('gameserver/destroysession')
|
||||
async destroySession(@Body('token') token)
|
||||
{
|
||||
return this.gameService.destroySession(token);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -166,8 +166,8 @@ export class GameService {
|
||||
|
||||
async declineInvitation(user : User, token : string)
|
||||
{
|
||||
// if (user.status === "In Game")
|
||||
// return new HttpException("You must finish your game before decline.", HttpStatus.FORBIDDEN)
|
||||
if (user.status === "In Game")
|
||||
return new HttpException("You must finish your game before decline.", HttpStatus.FORBIDDEN)
|
||||
console.log("On décline l'invitation")
|
||||
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokengame')
|
||||
.andWhere('tokengame.playerTwoUsername = :playerTwoUsername', {playerTwoUsername : user.username})
|
||||
@@ -178,6 +178,17 @@ export class GameService {
|
||||
return new HttpException("Invitation not found !", HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
async destroySession(token : string)
|
||||
{
|
||||
console.log("On détruit le token et la session qui va avec")
|
||||
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokengame')
|
||||
.where('tokengame.token = :token', {token : token})
|
||||
.getOne();
|
||||
if (tokenGame)
|
||||
return this.tokenGameRepository.remove(tokenGame);
|
||||
return new HttpException("Invitation not found !", HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
async acceptInvitation(user : User, token : string)
|
||||
{
|
||||
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokenGame')
|
||||
@@ -194,8 +205,8 @@ export class GameService {
|
||||
}
|
||||
|
||||
async requestIfAnotherUserHasRespondToquestForGame(user : User, token : string) {
|
||||
// if (user.status === "In Game")
|
||||
// return new HttpException("You can't do that.", HttpStatus.BAD_REQUEST)
|
||||
if (user.status === "In Game")
|
||||
return new HttpException("You can't do that.", HttpStatus.BAD_REQUEST)
|
||||
const tokenGame = await this.tokenGameRepository.createQueryBuilder('tokenGame')
|
||||
.where('tokenGame.token = :token', {token : token})
|
||||
.andWhere('tokenGame.isSecondUserAcceptedRequest = :isSecondUserAcceptedRequest', {isSecondUserAcceptedRequest : true})
|
||||
@@ -211,6 +222,9 @@ export class GameService {
|
||||
|
||||
async createGame(creategameDto : CreateGameDto)
|
||||
{
|
||||
if (creategameDto.playerOneUsername === "" || creategameDto.playerTwoUsername === ""
|
||||
|| creategameDto.playerOneUsername === creategameDto.playerTwoUsername)
|
||||
return HttpStatus.INTERNAL_SERVER_ERROR
|
||||
const game = this.gameRepository.create(creategameDto)
|
||||
game.isMatchIsFinished = false;
|
||||
this.gameRepository.save(game);
|
||||
|
||||
Reference in New Issue
Block a user