diff --git a/src/robot/Robot.ts b/src/robot/Robot.ts index 9ea162e..e2c76ee 100644 --- a/src/robot/Robot.ts +++ b/src/robot/Robot.ts @@ -168,13 +168,24 @@ export class Robot { if (!cards) { return; } - let cardIds = cards.map(o => o.id); - // let cardIds = [cardArr[0].id] + let cardIds: number[] = []; + let hasEatCard = false; + for (let card of cards) { + if (!targetCard || (targetCard && card.id !== targetCard.id)) { + cardIds.push(card.id); + } + if (targetCard && card.id == targetCard.id) { + hasEatCard = true + } + } log(`discard: ${self.sessionId} ${cardIds}`); - self.reply('discard_card_c2s', { - cards: cardIds, - target: targetCard.id - }); + let repData: any = { + cards: cardIds + } + if (hasEatCard) { + repData.target = targetCard.id + } + self.reply('discard_card_c2s', repData); } /** diff --git a/src/robot/RobotClient.ts b/src/robot/RobotClient.ts index 64de35c..390e46e 100644 --- a/src/robot/RobotClient.ts +++ b/src/robot/RobotClient.ts @@ -145,12 +145,24 @@ export class RobotClient implements Client { if (!cards) { return; } - let cardIds = cards.map(o => o.id); + let cardIds: number[] = []; + let hasEatCard = false; + for (let card of cards) { + if (!targetCard || (targetCard && card.id !== targetCard.id)) { + cardIds.push(card.id); + } + if (targetCard && card.id == targetCard.id) { + hasEatCard = true + } + } log(`discard: ${self.sessionId} ${cardIds}`); - self.reply('discard_card_c2s', { - cards: cardIds, - target: targetCard.id - }); + let repData: any = { + cards: cardIds + } + if (hasEatCard) { + repData.target = targetCard.id + } + self.reply('discard_card_c2s', repData); } /**