吃牌时过滤当前所出的牌是否在卡组中

This commit is contained in:
zhl 2020-12-25 17:06:13 +08:00
parent 14f61afad3
commit 51dbbed26a

View File

@ -18,11 +18,14 @@ export class EatCardCommand extends Command<CardGameState, { client: Client, car
return; return;
} }
let tmpCards = []; let tmpCards = [];
let cardIds = [];
for (let id of cards) { for (let id of cards) {
if (player.cards.has(id + '')) { if (player.cards.has(id + '')) {
if (!player.cards.get(id + '').number) { if (!player.cards.get(id + '').number) {
error(`${player.id} 的手牌 ${id} 数据有问题`); error(`${player.id} 的手牌 ${id} 数据有问题`);
continue;
} }
cardIds.push(id);
tmpCards.push(player.cards.get(id + '')); tmpCards.push(player.cards.get(id + ''));
} else { } else {
error(`${player.id} 出的牌 ${id} 在手牌中不存在`) error(`${player.id} 出的牌 ${id} 在手牌中不存在`)
@ -53,7 +56,7 @@ export class EatCardCommand extends Command<CardGameState, { client: Client, car
this.room.send(client,'eat_card_s2c', {errcode: 8, errmsg: '不可更改操作'}); this.room.send(client,'eat_card_s2c', {errcode: 8, errmsg: '不可更改操作'});
return ; return ;
} }
this.state.tmpActionMap.set(client.sessionId, cards); this.state.tmpActionMap.set(client.sessionId, cardIds);
return [new EatConfirmCommand().setPayload({timeUp: false})]; return [new EatConfirmCommand().setPayload({timeUp: false})];
} }