mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 18:29:14 +02:00
Cards Against Humanity and Apples to Apples
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user