import {Command} from "@colyseus/command"; import {CardGameState} from "../schema/CardGameState"; import {singleton} from "../../common/Singleton"; import {GameEnv} from "../../cfg/GameEnv"; import gameUtil from "../../utils/game.util"; import {debugRoom, error} from "../../common/Debug"; import {DiscardCommand} from "./DiscardCommand"; /** * 正常的抽卡 */ export class DrawCommand extends Command { async execute() { let sessionId = this.state.currentTurn; this.room.addCard(sessionId, singleton(GameEnv).roundDrawNum, 0); let maxTime = singleton(GameEnv).maxDiscardTime * 1000; let player = this.state.players.get(sessionId); let self = this; this.room.mainClock = this.clock.setTimeout(function () { self.room.mainClock.clear(); if (sessionId == self.state.currentTurn) { let client = self.room.getClient(sessionId); let card = player.cards.values().next().value; debugRoom('出牌时间到, 自动出牌: ', card.id); self.room.dispatcher.dispatch(new DiscardCommand(), {client, cards: [card.id], dtype: 1}); } }, maxTime + player.extraTime) // await this.delay((maxTime + player.extraTime) * 1000); } }