card_svr/src/rooms/commands/GameRestartCommand.ts
2020-12-14 13:15:47 +08:00

17 lines
544 B
TypeScript

import {Command} from "@colyseus/command";
import {CardGameState} from "../schema/CardGameState";
import {Client} from "colyseus";
import {PlayReadyCommand} from "./PlayReadyCommand";
export class GameRestartCommand extends Command<CardGameState, {client: Client}> {
execute({client} = this.payload) {
this.state.restartCount ++;
if (this.state.restartCount >= this.room.maxClients) {
this.room.stopSchedule('restart_schedule');
}
return [new PlayReadyCommand().setPayload({client})];
}
}