card_svr/src/rooms/commands/GiveUpCommand.ts
2020-12-03 19:22:37 +08:00

19 lines
613 B
TypeScript

import {Command} from "@colyseus/command";
import {CardGameState} from "../schema/CardGameState";
import {NextTurnCommand} from "./NextTurnCommand";
import {Client} from "colyseus";
import {TurnEndCommand} from "./TurnEndCommand";
/**
* 放弃吃牌
*/
export class GiveUpCommand extends Command<CardGameState, {client: Client}> {
execute({client} = this.payload) {
this.state.giveUpCount += 1;
this.room.broadcast('give_up_eat_s2c', {player: client.sessionId});
if (this.state.giveUpCount >= this.room.maxClients - 1) {
return [new TurnEndCommand()];
}
}
}