修改机器人的出牌逻辑

This commit is contained in:
zhl 2021-02-20 11:44:23 +08:00
parent 94a123f7e6
commit b048727ac3
2 changed files with 34 additions and 11 deletions

View File

@ -168,13 +168,24 @@ export class Robot {
if (!cards) { if (!cards) {
return; return;
} }
let cardIds = cards.map(o => o.id); let cardIds: number[] = [];
// let cardIds = [cardArr[0].id] 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}`); log(`discard: ${self.sessionId} ${cardIds}`);
self.reply('discard_card_c2s', { let repData: any = {
cards: cardIds, cards: cardIds
target: targetCard.id }
}); if (hasEatCard) {
repData.target = targetCard.id
}
self.reply('discard_card_c2s', repData);
} }
/** /**

View File

@ -145,12 +145,24 @@ export class RobotClient implements Client {
if (!cards) { if (!cards) {
return; 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}`); log(`discard: ${self.sessionId} ${cardIds}`);
self.reply('discard_card_c2s', { let repData: any = {
cards: cardIds, cards: cardIds
target: targetCard.id }
}); if (hasEatCard) {
repData.target = targetCard.id
}
self.reply('discard_card_c2s', repData);
} }
/** /**