23 lines
795 B
TypeScript
23 lines
795 B
TypeScript
|
|
import {Command} from "@colyseus/command";
|
|
import {CardGameState} from "../schema/CardGameState";
|
|
import {GameStateConst} from "../../constants/GameStateConst";
|
|
import gameUtil from "../../utils/game.util";
|
|
import {singleton} from "../../common/Singleton";
|
|
import {GameEnv} from "../../cfg/GameEnv";
|
|
|
|
|
|
export class BeginGameCommand extends Command<CardGameState, {}> {
|
|
|
|
execute() {
|
|
this.state.cardQueue = gameUtil.initCardQue();
|
|
for (let client of this.room.clients) {
|
|
let player = this.state.players.get(client.sessionId);
|
|
let cards = gameUtil.drawCard(this.state.cardQueue, player, singleton(GameEnv).initCardNum);
|
|
client.send('draw_card_s2c', cards);
|
|
}
|
|
this.state.gameState = GameStateConst.STATE_CHANGE_CARD;
|
|
}
|
|
|
|
}
|