Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert 3d6 to a playing card
# original idea and base logic from
dice_to_card(a,b,y) {
suits = {2:'H', 3:'C', 4:'D', 5:'S'}
if (y>1 and y<6) {
# number cards
rank = ceil(a/2) + (ceil(b/2)-1)*3
if rank==1 rank = 10
return rank, suits[y]
elif ((a==1 or a==6) and (b==1 or b==6)) {
# jokers
if y==1 return 'joker', 'lil'
else return 'joker', 'big'
else {
# face cards
ranks = ['J','Q','K','A']
suitnum = 2 + floor(y/3) + ((a==1 or a==6 or b==1 or b==6)?1:0)
return ranks[(a-b)%4], suits[suitnum]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment