调整机器人退出策略

This commit is contained in:
zhl 2021-07-12 11:53:12 +08:00
parent bab2553546
commit df148af42f
2 changed files with 8 additions and 0 deletions

View File

@ -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
}
})
}

View File

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