修正游戏结束广播参数缺少的bug

This commit is contained in:
zhl 2020-12-07 13:41:53 +08:00
parent 626524eecf
commit 7dc9f2ae99
2 changed files with 12 additions and 5 deletions

2
src/global.d.ts vendored
View File

@ -117,7 +117,7 @@ declare module "colyseus" {
* @param data
* @param options
*/
bGameResult(data?: any, options: any): void;
bGameResult(data?: any, options?: any): void;
/**
*
* @param client

View File

@ -2,9 +2,8 @@ import {Command} from "@colyseus/command";
import {CardGameState} from "../schema/CardGameState";
import {DrawCommand} from "./DrawCommand";
import {GameStateConst} from "../../constants/GameStateConst";
import {singleton} from "../../common/Singleton";
import {GameEnv} from "../../cfg/GameEnv";
import {PartResultCommand} from "./PartResultCommand";
import {PlayerStateConst} from "../../constants/PlayerStateConst";
import {error} from "../../common/Debug";
/**
*
@ -22,7 +21,15 @@ export class NextTurnCommand extends Command<CardGameState, {}> {
this.state.currentTurn = (this.state.currentTurn)
? sessionIds[(sessionIds.indexOf(this.state.currentTurn) + 1) % sessionIds.length]
: sessionIds[0];
return [new DrawCommand()]
let player = this.state.players.get(this.state.currentTurn);
if (!player) {
error('未找到玩家');
}
if (player.state == PlayerStateConst.PLAYER_DEAD) {
return [new NextTurnCommand()];
} else {
return [new DrawCommand()]
}
}
}