From 94a123f7e627fbac90bf5105456b8b908249ce73 Mon Sep 17 00:00:00 2001 From: zhl Date: Sat, 20 Feb 2021 10:43:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E7=9A=84=E5=87=BA=E7=89=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/robot/Robot.ts | 9 +++++++-- src/robot/RobotClient.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 6109870..9ea162e 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -158,9 +158,13 @@ export class Robot { */ @wait('maxDiscardTime') private async discard() { + let targetCard + if (this.room.state.cards.size == 1) { + targetCard =[...this.room.state.cards.values()][0]; + } let self = this; let cardArr = [...self.player.cards.values()]; - let cards = assistantUtil.checkTriple(cardArr); + let cards = assistantUtil.checkTriple(cardArr, targetCard); if (!cards) { return; } @@ -168,7 +172,8 @@ export class Robot { // let cardIds = [cardArr[0].id] log(`discard: ${self.sessionId} ${cardIds}`); self.reply('discard_card_c2s', { - cards: cardIds + cards: cardIds, + target: targetCard.id }); } diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index 78f7a7b..64de35c 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -135,16 +135,21 @@ export class RobotClient implements Client { */ @wait('maxDiscardTime') private async discard() { + let targetCard + if (this.svrstate.cards.size == 1) { + targetCard =[...this.svrstate.cards.values()][0]; + } let self = this; let cardArr = [...self.selfPlayer.cards.values()]; - let cards = assistantUtil.checkTriple(cardArr); + let cards = assistantUtil.checkTriple(cardArr, targetCard); if (!cards) { return; } let cardIds = cards.map(o => o.id); log(`discard: ${self.sessionId} ${cardIds}`); self.reply('discard_card_c2s', { - cards: cardIds + cards: cardIds, + target: targetCard.id }); }