From df148af42f6eff4b0b8991365de838376405cd2d Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 12 Jul 2021 11:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E9=80=80=E5=87=BA=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 4 ++++ src/rooms/GeneralRoom.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 6b5aded..0da5dbb 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -135,6 +135,10 @@ export class Robot { case GameStateConst.STATE_DICE_TURN: self.discard() break + case GameStateConst.STATE_GAME_OVER: + self.room.leave() + self.room.removeAllListeners() + break } }) } diff --git a/src/rooms/GeneralRoom.ts b/src/rooms/GeneralRoom.ts index 327f8bc..9b26b76 100644 --- a/src/rooms/GeneralRoom.ts +++ b/src/rooms/GeneralRoom.ts @@ -204,6 +204,10 @@ export class GeneralRoom extends Room { // 掉线逻辑 async onLeave(client: Client, consented: boolean) { + if (this.clients.length === 0) { + this.disconnect() + return + } if (this.state.gameState === GameStateConst.STATE_GAME_OVER || this.state.gameState === GameStateConst.STATE_WAIT_JOIN) { this.state.players.delete(client.sessionId) if (this.assistMap.has(client.sessionId)) {