correction de bugs mineurs
This commit is contained in:
@@ -64,8 +64,8 @@ export class GameService {
|
|||||||
if (grantTicketDto.isGameIsWithInvitation === true)
|
if (grantTicketDto.isGameIsWithInvitation === true)
|
||||||
{
|
{
|
||||||
const secondUser : Partial<User> = await this.userService.findOneByUsername(user.id.toString(), grantTicketDto.playerTwoUsername)
|
const secondUser : Partial<User> = await this.userService.findOneByUsername(user.id.toString(), grantTicketDto.playerTwoUsername)
|
||||||
if (!secondUser)
|
if (!secondUser || secondUser.username === user.username)
|
||||||
return new HttpException("The requested second player does not exist", HttpStatus.NOT_FOUND);
|
return new HttpException("The requested second player does not exist OR you want to play against yourself. :P", HttpStatus.NOT_FOUND);
|
||||||
const encryptedTextToReturn = await this.encryptToken(user.username + '_' + secondUser.username + '_'
|
const encryptedTextToReturn = await this.encryptToken(user.username + '_' + secondUser.username + '_'
|
||||||
+ grantTicketDto.gameOptions + '_' + grantTicketDto.isGameIsWithInvitation + '_' + new Date())
|
+ grantTicketDto.gameOptions + '_' + grantTicketDto.isGameIsWithInvitation + '_' + new Date())
|
||||||
const tok = this.tokenGameRepository.create(grantTicketDto);
|
const tok = this.tokenGameRepository.create(grantTicketDto);
|
||||||
@@ -185,8 +185,16 @@ export class GameService {
|
|||||||
.where('tokengame.token = :token', {token : token})
|
.where('tokengame.token = :token', {token : token})
|
||||||
.getOne();
|
.getOne();
|
||||||
if (tokenGame)
|
if (tokenGame)
|
||||||
|
{
|
||||||
|
const playerOne = await this.userRepository.findOneBy({username : tokenGame.playerOneUsername})
|
||||||
|
const playerTwo = await this.userRepository.findOneBy({username : tokenGame.playerTwoUsername})
|
||||||
|
playerOne.status = "Connected"
|
||||||
|
playerTwo.status = "Connected"
|
||||||
|
this.userRepository.save(playerOne)
|
||||||
|
this.userRepository.save(playerTwo)
|
||||||
return this.tokenGameRepository.remove(tokenGame);
|
return this.tokenGameRepository.remove(tokenGame);
|
||||||
return new HttpException("Invitation not found !", HttpStatus.NOT_FOUND)
|
}
|
||||||
|
return new HttpException("Token not found !", HttpStatus.NOT_FOUND)
|
||||||
}
|
}
|
||||||
|
|
||||||
async acceptInvitation(user : User, token : string)
|
async acceptInvitation(user : User, token : string)
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
.then( x => x.json() );
|
.then( x => x.json() );
|
||||||
allUsers = await fetch('http://transcendance:8080/api/v2/user/all')
|
allUsers = await fetch('http://transcendance:8080/api/v2/user/all')
|
||||||
.then( x => x.json() );
|
.then( x => x.json() );
|
||||||
|
|
||||||
options.playerOneUsername = user.username;
|
options.playerOneUsername = user.username;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user