修改未点击确认玩家的判断逻辑

This commit is contained in:
zhl 2020-12-14 20:40:50 +08:00
parent f89f862234
commit bd7c8dfae5
2 changed files with 14 additions and 5 deletions

View File

@ -2,15 +2,24 @@ import {Command} from "@colyseus/command";
import {CardGameState} from "../schema/CardGameState";
import {Client} from "colyseus";
import {PlayReadyCommand} from "./PlayReadyCommand";
import {PlayerStateConst} from "../../constants/PlayerStateConst";
import {error} from "../../common/Debug";
export class GameRestartCommand extends Command<CardGameState, {client: Client}> {
execute({client} = this.payload) {
this.state.restartCount ++;
if (this.state.restartCount >= this.room.maxClients) {
this.room.stopSchedule('restart_schedule');
let player = this.state.players.get(client.sessionId);
if (player) {
this.state.restartCount ++;
player.state = PlayerStateConst.PLAYER_NORMAL;
if (this.state.restartCount >= this.room.maxClients) {
this.room.stopSchedule('restart_schedule');
}
} else {
error(`${client.sessionId} not found!!`)
}
return [new PlayReadyCommand().setPayload({client})];
// return [new PlayReadyCommand().setPayload({client})];
}
}

View File

@ -69,7 +69,7 @@ export class GameResultCommand extends Command<CardGameState, {}> {
} else if (self.state.restartCount < self.room.maxClients){
// 如果点击重开的玩家少于房间最大人数, 则把房间设为公开, 等待其他玩家匹配进来
for (let [,player] of self.state.players) {
if (player.state !== PlayerStateConst.PLAYER_READY) {
if (player.state !== PlayerStateConst.PLAYER_NORMAL) {
let client = self.room.getClient(player);
debugRoom(`清除没点击重新开始的玩家 ${client.sessionId}`);
client.leave();