Skip to content
This repository has been archived by the owner on Jan 31, 2021. It is now read-only.

Commit

Permalink
When picking random, don't pick the same card twice
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyissillyyy committed Aug 17, 2018
1 parent 34d8575 commit 48423ec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cards-against-humanity",
"version": "2.1.1",
"version": "2.1.2",
"description": "Cards Against Humanity, but for Discord!",
"main": "CAH.js",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion structures/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ module.exports = class Player {
return this.turn(channel, czar, black, deck, chosenCards); // eslint-disable-line consistent-return
}
if (choices.size < black.pick) {
for (let i = 0; i < black.pick; i++) chosen.push(hand[Math.floor(Math.random() * hand.length)]);
for (let i = 0; i < black.pick; i++) {
const valid = hand.filter(card => !chosen.includes(card));
chosen.push(valid[Math.floor(Math.random() * valid.length)]);
}
this.strikes++;
}
if (chosen.includes('<Blank>')) {
Expand Down

0 comments on commit 48423ec

Please sign in to comment.