修改未点击确认玩家的判断逻辑
This commit is contained in:
parent
f89f862234
commit
bd7c8dfae5
@ -2,15 +2,24 @@ import {Command} from "@colyseus/command";
|
|||||||
import {CardGameState} from "../schema/CardGameState";
|
import {CardGameState} from "../schema/CardGameState";
|
||||||
import {Client} from "colyseus";
|
import {Client} from "colyseus";
|
||||||
import {PlayReadyCommand} from "./PlayReadyCommand";
|
import {PlayReadyCommand} from "./PlayReadyCommand";
|
||||||
|
import {PlayerStateConst} from "../../constants/PlayerStateConst";
|
||||||
|
import {error} from "../../common/Debug";
|
||||||
|
|
||||||
|
|
||||||
export class GameRestartCommand extends Command<CardGameState, {client: Client}> {
|
export class GameRestartCommand extends Command<CardGameState, {client: Client}> {
|
||||||
|
|
||||||
execute({client} = this.payload) {
|
execute({client} = this.payload) {
|
||||||
this.state.restartCount ++;
|
let player = this.state.players.get(client.sessionId);
|
||||||
if (this.state.restartCount >= this.room.maxClients) {
|
if (player) {
|
||||||
this.room.stopSchedule('restart_schedule');
|
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})];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ export class GameResultCommand extends Command<CardGameState, {}> {
|
|||||||
} else if (self.state.restartCount < self.room.maxClients){
|
} else if (self.state.restartCount < self.room.maxClients){
|
||||||
// 如果点击重开的玩家少于房间最大人数, 则把房间设为公开, 等待其他玩家匹配进来
|
// 如果点击重开的玩家少于房间最大人数, 则把房间设为公开, 等待其他玩家匹配进来
|
||||||
for (let [,player] of self.state.players) {
|
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);
|
let client = self.room.getClient(player);
|
||||||
debugRoom(`清除没点击重新开始的玩家 ${client.sessionId}`);
|
debugRoom(`清除没点击重新开始的玩家 ${client.sessionId}`);
|
||||||
client.leave();
|
client.leave();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user