Skip to content

Instantly share code, notes, and snippets.

@shuuki
Created February 3, 2017 01:41
Show Gist options
  • Save shuuki/b8c17afddce51fb58022c252febb4f5f to your computer and use it in GitHub Desktop.
Save shuuki/b8c17afddce51fb58022c252febb4f5f to your computer and use it in GitHub Desktop.
LIKE MAGIC
var
names = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ace', 'Jack', 'Queen', 'King'],
pips = ['1','2','3','4','5','6','7','8','9','A','J','Q','K'],
suits = ['Dirt', 'Wind', 'Sun', 'Sea'],
arcana = ['Star', 'World', 'Star', 'Moon', 'Priest', 'Temperance', 'Strength', 'Dream', 'Hermit', 'Tower', 'Chariot', 'Desire', 'Judgement', 'Devil', 'Hanged Man', 'Chance', 'Emperor', 'Chance']
//
function shuffle(a) {
var x = a.length,
t,i;
while (x) {
i = Math.floor(Math.random() * x--);
t = a[x];
a[x] = a[i];
a[i] = t;
}
return a;
}
function deck() {
var deck = [],
j,k,l;
for (j in suits) {
for (k in names) {
deck.push(names[k] + ' of ' + suits[j])
};
};
for (l in arcana) {
deck.push(arcana[l])
};
return deck;
}
//
var hand = shuffle(deck())
console.log(hand)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment