Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,31 @@
function Card(pip, suit) {
this.pip = pip;
this.suit = suit;
this.toString = function () {
return this.pip + ' ' + this.suit;
};
}
function Deck() {
var pips = '2 3 4 5 6 7 8 9 10 Jack Queen King Ace'.split(' ');
var suits = 'Clubs Hearts Spades Diamonds'.split(' ');
this.deck = [];
for (var i = 0; i < suits.length; i++)
for (var j = 0; j < pips.length; j++)
this.deck.push(new Card(pips[j], suits[i]));
this.toString = function () {
return '[' + this.deck.join(', ') + ']';
};
this.shuffle = function () {
for (var i = 0; i < this.deck.length; i++)
this.deck[i] = this.deck.splice(
parseInt(this.deck.length * Math.random()), 1, this.deck[i])[0];
};
this.deal = function () {
return this.deck.shift();
};
}