fix: user quit while playing
This commit is contained in:
parent
8564088a3b
commit
e93790445f
1 changed files with 3 additions and 4 deletions
|
|
@ -187,17 +187,16 @@ class StateI {
|
||||||
const winner = game.checkWinner() ?? 'left';
|
const winner = game.checkWinner() ?? 'left';
|
||||||
let player: PUser | undefined = undefined;
|
let player: PUser | undefined = undefined;
|
||||||
if ((player = this.users.get(game.userLeft)) !== undefined) {
|
if ((player = this.users.get(game.userLeft)) !== undefined) {
|
||||||
chat_text += (this.fastify.db.getUser(player.id)?.name ?? player.id) + ' and ';
|
|
||||||
// chat_text += player.id + ' and ';
|
|
||||||
player.currentGame = null;
|
player.currentGame = null;
|
||||||
player.socket.emit('gameEnd', winner);
|
player.socket.emit('gameEnd', winner);
|
||||||
}
|
}
|
||||||
|
chat_text += (this.fastify.db.getUser(game.userLeft)?.name ?? game.userLeft) +' and ';
|
||||||
if ((player = this.users.get(game.userRight)) !== undefined) {
|
if ((player = this.users.get(game.userRight)) !== undefined) {
|
||||||
chat_text += (this.fastify.db.getUser(player.id)?.name ?? player.id);
|
|
||||||
// chat_text += player.id;
|
|
||||||
player.currentGame = null;
|
player.currentGame = null;
|
||||||
player.socket.emit('gameEnd', winner);
|
player.socket.emit('gameEnd', winner);
|
||||||
}
|
}
|
||||||
|
chat_text += (this.fastify.db.getUser(game.userRight)?.name ?? game.userRight);
|
||||||
|
this.fastify.log.info('chat_text:'+ chat_text);
|
||||||
const rOutcome = game.checkWinner();
|
const rOutcome = game.checkWinner();
|
||||||
let outcome: PongGameOutcome = 'other';
|
let outcome: PongGameOutcome = 'other';
|
||||||
if (rOutcome === 'left') { outcome = 'winL'; }
|
if (rOutcome === 'left') { outcome = 'winL'; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue