17 lines
544 B
TypeScript
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})];
|
|
}
|
|
}
|