import {Command} from "@colyseus/command"; import {CardGameState} from "../schema/CardGameState"; import {Player} from "../schema/Player"; import {Client} from "colyseus"; /** * 玩家成功加入房间 */ export class OnJoinCommand extends Command { execute({client}: { client: Client }) { let team = this.state.players.size / 2 | 0; this.state.players.set(client.sessionId, new Player(0, team)); if (this.state.players.size >= this.room.maxClients) { this.room.lock(); this.state.gameState = 1; } this.room.broadcast("player_join", `${client.sessionId}`, {except: client}); } }