1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
static const char* cardnames[] =
{"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"};
static const char* suitnames[] =
{"Spades","Hearts","Clubs","Diamonds"};
string GetCardName(int cardid)
{
// note card IDs are zero based, not 1 based
// so 0= Ace of Spades, etc
// 1 based is unnatural and harder to work with unless 0 has a special meaning
// (which it doesn't appear to in this case)
if( cardid >= 52 )
return "Joker";
return string(cardnames[cardid % 13]) + " of " + suitnames[cardid / 13];
}
| |