mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Fix cards not being removed from hand
This commit is contained in:
@@ -42,7 +42,7 @@ module.exports = class Player {
|
|||||||
const chosen = [];
|
const chosen = [];
|
||||||
for (let i = 0; i < black.pick; i++) {
|
for (let i = 0; i < black.pick; i++) {
|
||||||
const valid = hand.filter(card => !chosen.includes(card));
|
const valid = hand.filter(card => !chosen.includes(card));
|
||||||
chosen.push(escapeMarkdown(valid[Math.floor(Math.random() * valid.length)]));
|
chosen.push(valid[Math.floor(Math.random() * valid.length)]);
|
||||||
}
|
}
|
||||||
for (const card of chosen) this.hand.delete(card);
|
for (const card of chosen) this.hand.delete(card);
|
||||||
chosenCards.push({ id: this.id, cards: chosen });
|
chosenCards.push({ id: this.id, cards: chosen });
|
||||||
@@ -80,7 +80,7 @@ module.exports = class Player {
|
|||||||
return;
|
return;
|
||||||
} else if (existing) {
|
} else if (existing) {
|
||||||
await msg.react(SUCCESS_EMOJI_ID || '✅');
|
await msg.react(SUCCESS_EMOJI_ID || '✅');
|
||||||
chosen.push(escapeMarkdown(existing));
|
chosen.push(existing);
|
||||||
}
|
}
|
||||||
if (chosen.length >= black.pick * (gambled ? 2 : 1)) collector.stop();
|
if (chosen.length >= black.pick * (gambled ? 2 : 1)) collector.stop();
|
||||||
});
|
});
|
||||||
@@ -89,7 +89,7 @@ module.exports = class Player {
|
|||||||
const count = black.pick - chosen.length;
|
const count = black.pick - chosen.length;
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
const valid = hand.filter(card => !chosen.includes(card));
|
const valid = hand.filter(card => !chosen.includes(card));
|
||||||
chosen.push(escapeMarkdown(valid[Math.floor(Math.random() * valid.length)]));
|
chosen.push(valid[Math.floor(Math.random() * valid.length)]);
|
||||||
}
|
}
|
||||||
this.strikes++;
|
this.strikes++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user