diff --git a/back/volume/src/pong/game/Game.ts b/back/volume/src/pong/game/Game.ts index 890d08c..b3c3b99 100644 --- a/back/volume/src/pong/game/Game.ts +++ b/back/volume/src/pong/game/Game.ts @@ -100,6 +100,7 @@ export class Game { if (this.timer === null && this.players.length === 2) { this.ball = new Ball(new Point(this.map.size.x / 2, this.map.size.y / 2)) this.players.forEach((p) => { + this.pongService.setInGame(p.name) p.newGame() }) this.playing = true diff --git a/back/volume/src/pong/game/Player.ts b/back/volume/src/pong/game/Player.ts index 934838f..5727d51 100644 --- a/back/volume/src/pong/game/Player.ts +++ b/back/volume/src/pong/game/Player.ts @@ -32,5 +32,6 @@ export class Player { newGame (): void { this.score = 0 this.paddle = new Paddle(this.paddleCoords, this.mapSize) + } } diff --git a/back/volume/src/pong/pong.service.ts b/back/volume/src/pong/pong.service.ts index df1e42c..8845150 100644 --- a/back/volume/src/pong/pong.service.ts +++ b/back/volume/src/pong/pong.service.ts @@ -23,6 +23,13 @@ export class PongService { player.winrate = (100 * player.wins) / player.matchs player.rank = (await this.usersService.getRank(player.ftId)) + 1 player.results.push(result) + player.status = "online" + await this.usersService.save(player) + } + + async setInGame (playerName: string): Promise { + const player = await this.usersService.findUserByName(playerName) + player.status = "in-game" await this.usersService.save(player) }