Files
xiao/structures/cards-against-humanity/Deck.js
T
2021-03-13 13:10:47 -05:00

21 lines
344 B
JavaScript

const { shuffle } = require('../util/Util');
module.exports = class Deck {
constructor(cards) {
this.cards = cards;
this.deck = shuffle(cards);
}
draw() {
if (!this.deck.length) this.reset();
const card = this.deck[0];
this.deck.shift();
return card;
}
reset() {
this.deck = shuffle(this.cards);
return this.deck;
}
};