card_svr/src/rooms/commands/NextTurnCommand.ts

21 lines
598 B
TypeScript

import {Command} from "@colyseus/command";
import {CardGameState} from "../schema/CardGameState";
import {DrawCommand} from "./DrawCommand";
/**
* 下一轮
*/
export class NextTurnCommand extends Command<CardGameState, {}> {
execute() {
this.state.gameState = 2;
this.state.subTurn = '';
const sessionIds = [...this.state.players.keys()];
this.state.currentTurn = (this.state.currentTurn)
? sessionIds[(sessionIds.indexOf(this.state.currentTurn) + 1) % sessionIds.length]
: sessionIds[0];
return [new DrawCommand()]
}
}