暂停和恢复增加游戏模式判定

This commit is contained in:
zhl 2021-03-24 13:12:59 +08:00
parent 3ece3776e2
commit b2659ad6e8
2 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,12 @@ import { Client } from 'colyseus'
export class PauseCommand extends Command<CardGameState, { client: Client }> { export class PauseCommand extends Command<CardGameState, { client: Client }> {
execute({ client } = this.payload) { execute({ client } = this.payload) {
if (this.state.mode !== 3) {
client.send('pause_s2c', {
errcode: 1,
errmsg: '当前模式不能暂停'})
return
}
let result = this.room.pauseAllSchedule() let result = this.room.pauseAllSchedule()
client.send('pause_s2c', {}) client.send('pause_s2c', {})
} }

View File

@ -5,6 +5,12 @@ import { Client } from 'colyseus'
export class ResumeCommand extends Command<CardGameState, {client: Client}> { export class ResumeCommand extends Command<CardGameState, {client: Client}> {
execute({client} = this.payload) { execute({client} = this.payload) {
if (this.state.mode !== 3) {
client.send('resume_s2c', {
errcode: 1,
errmsg: '当前模式不能暂停'})
return
}
this.room.resumeAllSchedule() this.room.resumeAllSchedule()
client.send('resume_s2c', {}) client.send('resume_s2c', {})
} }