{"size": 502, "ext": "js", "max_stars_repo_path": "gameServer/modules/deck.js", "max_stars_repo_name": "btalanski/CartasContraAHumanidadeWeb", "max_stars_repo_stars_event_min_datetime": "2020-11-29T00:03:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-29T00:03:29.000Z", "max_issues_repo_path": "gameServer/modules/deck.js", "max_issues_repo_name": "btalanski/CartasContraAHumanidadeWeb", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "gameServer/modules/deck.js", "max_forks_repo_name": "btalanski/CartasContraAHumanidadeWeb", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.9166666667, "max_line_length": 54, "alphanum_fraction": 0.4820717131}
const shuffle = require('lodash/shuffle');

class Deck {
    constructor(cards = []) {
        this.cards = cards;
        this.shuffle();
    }

    shuffle(){
        this.cards = shuffle(this.cards);
    }

    pullCard(total) {
        return this.cards.reduce((hand, card, i) => {
            if (i <= total - 1) {
                const selectedCard = this.cards.pop();
                hand.push(selectedCard);
            }
            return hand;
        }, []);
    }
}

module.exports = Deck;