{"size": 1389, "ext": "js", "max_stars_repo_path": "src/classes/deck.js", "max_stars_repo_name": "Identity-labs/distributed-texasholdem", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/classes/deck.js", "max_issues_repo_name": "Identity-labs/distributed-texasholdem", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/classes/deck.js", "max_forks_repo_name": "Identity-labs/distributed-texasholdem", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.7222222222, "max_line_length": 62, "alphanum_fraction": 0.5032397408}
const Card = require('./card');

// representation of a deck of standard (52) playing cards
const Deck = function () {
	this.cards = [];

	const constructor = function (deck) {
		const suits = ["♠", "♥", "♦", "♣"];
		for (let i = 0; i < suits.length; i++) {
			for (let j = 1; j <= 13; j++) {
				if (j === 1) {
					deck.cards.push(new Card('A', suits[i]));
				} else if (j === 11) {
					deck.cards.push(new Card('J', suits[i]));
				} else if (j === 12) {
					deck.cards.push(new Card('Q', suits[i]));
				} else if (j === 13) {
					deck.cards.push(new Card('K', suits[i]));
				} else {
					deck.cards.push(new Card(j, suits[i]));
				}
			}
		}
	}(this);

	this.shuffle = () => {
		this.cards = [];
		const suits = ["♠", "♥", "♦", "♣"];
		for (let i = 0; i < suits.length; i++) {
			for (let j = 1; j <= 13; j++) {
				if (j === 1) {
					this.cards.push(new Card('A', suits[i]));
				} else if (j === 11) {
					this.cards.push(new Card('J', suits[i]));
				} else if (j === 12) {
					this.cards.push(new Card('Q', suits[i]));
				} else if (j === 13) {
					this.cards.push(new Card('K', suits[i]));
				} else {
					this.cards.push(new Card(j, suits[i]));
				}
			}
		}
	}

	this.dealRandomCard = () => {
		const index = Math.floor(Math.random() * this.cards.length);
		value = this.cards[index];
		this.cards.splice(index, 1);
		return value;
	};
};

module.exports = Deck;