I’ve been wondering that the past few days. This is how I thought of doint it…
here is how I would make the deck…
cards = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king", "ace"];
types = ["hearts", "diamonds", "clubs", "spades"];
deck = new Array();
function buildDeck() {
for (var i=0; i<cards.length; i++) {
for (var k=0; k<types.length; k++) {
var curCard = cards* + " of " + types[k];
deck.push(curCard);
}
}
}
buildDeck();
And here is how i would shuffle the deck
function shuffleDeck() {
var cardPos = new Array(52);
tempDeck = new Array(52);
var i=0;
while (i<deck.length) {
var ind = random(52);
if (cardPos[ind] == undefined) {
cardPos[ind] = i;
tempDeck[ind] = deck*;
i++;
}
}
deck = tempDeck;
}
shuffleDeck();
Just curious as to how you would all go about doing it