增加暂停计时的超时自动恢复
This commit is contained in:
parent
6b712babcc
commit
57a041e5b7
@ -34,4 +34,9 @@ export class ClockNameConst {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
public static readonly WAITING_PREPARE = 'waiting_prepare'
|
public static readonly WAITING_PREPARE = 'waiting_prepare'
|
||||||
|
/**
|
||||||
|
* 客户端暂停
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
public static readonly CLIENT_PAUSE = 'client_pause'
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { Command } from '@colyseus/command'
|
import { Command } from '@colyseus/command'
|
||||||
import { CardGameState } from '../schema/CardGameState'
|
import { CardGameState } from '../schema/CardGameState'
|
||||||
import { Client } from 'colyseus'
|
import { Client } from 'colyseus'
|
||||||
|
import { debugRoom } from '../../common/Debug'
|
||||||
|
import { TurnEndCommand } from './TurnEndCommand'
|
||||||
|
import { ClockNameConst } from '../../constants/ClockNameConst'
|
||||||
|
|
||||||
export class PauseCommand extends Command<CardGameState, { client: Client }> {
|
export class PauseCommand extends Command<CardGameState, { client: Client }> {
|
||||||
|
|
||||||
@ -12,6 +15,12 @@ export class PauseCommand extends Command<CardGameState, { client: Client }> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let result = this.room.pauseAllSchedule()
|
let result = this.room.pauseAllSchedule()
|
||||||
|
let self = this
|
||||||
|
let timeOverPause = function () {
|
||||||
|
debugRoom('客户端暂停时间到, 自动恢复')
|
||||||
|
self.room.resumeAllSchedule()
|
||||||
|
}
|
||||||
|
this.room.beginSchedule(60 * 1000, timeOverPause, ClockNameConst.CLIENT_PAUSE)
|
||||||
client.send('pause_s2c', {})
|
client.send('pause_s2c', {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { Command } from '@colyseus/command'
|
import { Command } from '@colyseus/command'
|
||||||
import { CardGameState } from '../schema/CardGameState'
|
import { CardGameState } from '../schema/CardGameState'
|
||||||
import { Client } from 'colyseus'
|
import { Client } from 'colyseus'
|
||||||
|
import { ClockNameConst } from '../../constants/ClockNameConst'
|
||||||
|
|
||||||
export class ResumeCommand extends Command<CardGameState, {client: Client}> {
|
export class ResumeCommand extends Command<CardGameState, {client: Client}> {
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ export class ResumeCommand extends Command<CardGameState, {client: Client}> {
|
|||||||
errmsg: '当前模式不能暂停'})
|
errmsg: '当前模式不能暂停'})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
this.room.stopSchedule(ClockNameConst.CLIENT_PAUSE)
|
||||||
this.room.resumeAllSchedule()
|
this.room.resumeAllSchedule()
|
||||||
client.send('resume_s2c', {})
|
client.send('resume_s2c', {})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user