fix draw game
+ status update in generateToken()
This commit is contained in:
@@ -274,7 +274,7 @@ export class GameSession {
|
||||
gc.scoreRight = 3;
|
||||
}
|
||||
else
|
||||
{ // TODO: match draw, verifier la getion coté Nest
|
||||
{
|
||||
gc.scoreLeft = 0;
|
||||
gc.scoreRight = 0;
|
||||
}
|
||||
|
||||
@@ -87,10 +87,12 @@ export class GameService {
|
||||
if (user.status === STATUS.IN_POOL || user.status === STATUS.IN_GAME)
|
||||
{
|
||||
await this.deleteToken(user);
|
||||
user.status = STATUS.CONNECTED;
|
||||
if (user.status === STATUS.IN_POOL) {
|
||||
user.status = STATUS.CONNECTED;
|
||||
}
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
if (grantTicketDto.isGameIsWithInvitation === true)
|
||||
if (grantTicketDto.isGameIsWithInvitation === true && user.status !== STATUS.IN_GAME)
|
||||
{
|
||||
const secondUser : Partial<User> = await this.userService.findOne(grantTicketDto.playerTwoUsername)
|
||||
if (!secondUser || secondUser.username === user.username)
|
||||
@@ -105,7 +107,7 @@ export class GameService {
|
||||
this.userService.updateStatus(user.id, "In Pool")
|
||||
return res.status(HttpStatus.OK).json({ token : encryptedTextToReturn });
|
||||
}
|
||||
else if (grantTicketDto.isGameIsWithInvitation === false) {
|
||||
else if (grantTicketDto.isGameIsWithInvitation === false && user.status !== STATUS.IN_GAME) {
|
||||
const encryptedTextToReturn = await this.encryptToken(user.username + '_'
|
||||
+ grantTicketDto.gameOptions + '_' + grantTicketDto.isGameIsWithInvitation + '_' + new Date())
|
||||
const tok = this.tokenGameRepository.create(grantTicketDto);
|
||||
@@ -280,6 +282,7 @@ export class GameService {
|
||||
{
|
||||
this.userService.incrementDraws(playerOne.id)
|
||||
this.userService.incrementDraws(playerTwo.id)
|
||||
console.log("DRAW NEST");
|
||||
}
|
||||
else if (game.playerOneUsernameResult < game.playerTwoUsernameResult)
|
||||
{
|
||||
|
||||
@@ -193,7 +193,7 @@ export class UsersService {
|
||||
.getOne();
|
||||
if (!user.stats || !user)
|
||||
throw new HttpException(`The user's stats could not be found.`,HttpStatus.NOT_FOUND);
|
||||
user.stats.winGame++;
|
||||
user.stats.drawGame++;
|
||||
user.stats.totalGame++;
|
||||
this.userRepository.save(user);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user