From e7021949a6034e017a05845b6b454f67bd3bd4b0 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 30 Mar 2021 14:08:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E5=A4=A7=E5=B0=8F=E5=87=BA=E7=89=8C?= =?UTF-8?q?=E5=90=8E,=20=E5=B0=86card=E4=BF=A1=E6=81=AF=E5=AD=98=E5=85=A5p?= =?UTF-8?q?layer.cardQueue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rooms/commands/DiceCommand.ts | 5 ++++- src/rooms/commands/DiceNextTurnCommand.ts | 3 +++ src/rooms/commands/DiceTurnEndCommand.ts | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/rooms/commands/DiceCommand.ts b/src/rooms/commands/DiceCommand.ts index 89bd68b..33c3b3d 100644 --- a/src/rooms/commands/DiceCommand.ts +++ b/src/rooms/commands/DiceCommand.ts @@ -4,6 +4,7 @@ import { Client } from 'colyseus' import { error } from '../../common/Debug' import { DiceResultCommand } from './DiceResultCommand' import { GameStateConst } from '../../constants/GameStateConst' +import gameUtil from '../../utils/game.util' /** * 出一张牌比大小 @@ -28,6 +29,7 @@ export class DiceCommand extends Command { async execute() { this.state.round += 1 this.state.updateGameState(GameStateConst.STATE_DICE_TURN) + for (let [,player] of this.state.players) { + player.cardQueue.clear() + } return [new DiceDrawCommand()] } } diff --git a/src/rooms/commands/DiceTurnEndCommand.ts b/src/rooms/commands/DiceTurnEndCommand.ts index f290c21..792c8de 100644 --- a/src/rooms/commands/DiceTurnEndCommand.ts +++ b/src/rooms/commands/DiceTurnEndCommand.ts @@ -1,9 +1,16 @@ import { Command } from '@colyseus/command' import { CardGameState } from '../schema/CardGameState' import { DiceNextTurnCommand } from './DiceNextTurnCommand' +import gameUtil from '../../utils/game.util' +import { GameResultCommand } from './GameResultCommand' export class DiceTurnEndCommand extends Command { async execute() { + // 判断是否胜利 + let result = gameUtil.checkGameEnd(this.state) + if (result) { + return [new GameResultCommand()] + } return [new DiceNextTurnCommand()] } }