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)) {