diff --git a/src/rooms/commands/PauseCommand.ts b/src/rooms/commands/PauseCommand.ts index d0656a3..3010245 100644 --- a/src/rooms/commands/PauseCommand.ts +++ b/src/rooms/commands/PauseCommand.ts @@ -5,6 +5,12 @@ import { Client } from 'colyseus' export class PauseCommand extends Command { execute({ client } = this.payload) { + if (this.state.mode !== 3) { + client.send('pause_s2c', { + errcode: 1, + errmsg: '当前模式不能暂停'}) + return + } let result = this.room.pauseAllSchedule() client.send('pause_s2c', {}) } diff --git a/src/rooms/commands/ResumeCommand.ts b/src/rooms/commands/ResumeCommand.ts index 0c9d398..7c776fd 100644 --- a/src/rooms/commands/ResumeCommand.ts +++ b/src/rooms/commands/ResumeCommand.ts @@ -5,6 +5,12 @@ import { Client } from 'colyseus' export class ResumeCommand extends Command { execute({client} = this.payload) { + if (this.state.mode !== 3) { + client.send('resume_s2c', { + errcode: 1, + errmsg: '当前模式不能暂停'}) + return + } this.room.resumeAllSchedule() client.send('resume_s2c', {}) }