Card Encoding
Card Encoding
Card values are encoded in the database using the poker-eval scheme:
def cardFromValueSuit(value, suit): """ 0=none, 1-13=2-Ah 14-26=2-Ad 27-39=2-Ac 40-52=2-As """ if suit == 'h': return(value-1) elif suit == 'd': return(value+12) elif suit == 'c': return(value+25) elif suit == 's': return(value+38) else: return(0) def valueSuitFromCard(card): """ Function to convert a card stored in the database (int 0-52) into value and suit like 9s, 4c etc """ if card < 0 or card > 52: return('') else: return( ['', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', 'Th', 'Jh', 'Qh', 'Kh', 'Ah' , '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', 'Td', 'Jd', 'Qd', 'Kd', 'Ad' , '2c', '3c', '4c', '5c', '6c', '7c', '8c', '9c', 'Tc', 'Jc', 'Qc', 'Kc', 'Ac' , '2s', '3s', '4s', '5s', '6s', '7s', '8s', '9s', 'Ts', 'Js', 'Qs', 'Ks', 'As' ][card] )