Need some added help perfecting a game

Posted by Dralnu on Thu 09 Jun 2005 12:40 AM — 6 posts, 24,660 views.

USA #0
Been working on my card games, got blackjack somehwat finished I think and now I'm trying to add in a poker bit before I go in to compile, but before I go into that, I need some help with the card list. So far its pretty much:

const struct mycards allcards[52]={
{2c, "2 of clubs"},
{2h, "2 of hearts"},
{2d, "2 of diamonds"},
{2s, "2 of spades"},
{3c, "3 of clubs"},
{3h, "3 of hearts"},
{3d, "3 of diamonds"},
{3s, "3 of spades"},
{4c, "4 of clubs"},
{4h, "4 of hearts"},
{4d, "4 of diamonds"},
{4s, "4 of spades"},
{5c, "5 of clubs"},
{5h, "5 of hearts"},
{5d, "5 of diamonds"},
{5s, "5 of spades"},
{6c, "6 of clubs"},
{6h, "6 of hearts"},
{6d, "6 of diamonds"},
{6s, "6 of spades"},
{7c, "7 of clubs"},
{7h, "7 of hearts"},
{7d, "7 of diamonds"},
{7s, "7 of spades"},
{8c, "8 of clubs"},
{8h, "8 of hearts"},
{8d, "8 of diamonds"},
{8s, "8 of spades"},
{9c, "9 of clubs"},
{9h, "9 of hearts"},
{9d, "9 of diamonds"},
{9s, "9 of spades"},
{10c, "10 of clubs"},
{10h, "10 of hearts"},
{10d, "10 of diamonds"},
{10s, "10 of spades"},
{Jc, "Jack of clubs"},
{Jh, "Jack of hearts"},
{Jd, "Jack of diamonds"},
{Js, "Jack of spades"},
{Qc, "Queen of clubs"},
{Qh, "Queen of hearts"},
{Qd, "Queen of diamonds"},
{Qs, "Queen of spades"},
{Kc, "King of clubs"},
{Kh, "King of hearts"},
{Kd, "King of diamonds"},
{Ks, "King of spades"},
{1c, "Ace of clubs"},
{1h, "Ace of hearts"},
{1d, "Ace of diamonds"},
{1s, "Ace of spades"}
};

I was wondering if this would work to run the game on, or if I would need to instead go to a 3 digit code, similar to

{131, "King of Hearts"}

to be able to use the same cardlist for more then one game.
USA #1
That should work fine as is so long as you make it a global array.
USA #2
thanks. I'll post again later if I need anymore help
USA #3
Did this code from your first post actually compiler? I'm not sure the compiler would know what to do with the literal 'Kh'. You'd have to use strings or number codes. You could do it nicely with hexadecimal. Use the first digit for the color (0 --> spades, 1 --> clubs, 2 --> diamonds, 3 --> hearts or whatever) and the second digit for the card: 2, 3, 4, 5, 6, 7, 9, 9, a --> ten, b --> jack, c --> queen, d --> king. Ace would be 1 or e, depending on how you want it to rank with the other cards. So, 0x04 would be a 4 of spades; 0x3a would be a ten of hearts.
USA #4
I dunno how to do hexadecimal, but that would be nice. Right now I'm trying to get a few things fixed, especially a config I added that doesn't seem to wanna work.
USA #5
0x10 is how you write 16 in hexadecimal. The general format is 0xY where Y is your hexadecimal number.

If you google for this: "0x3a in decimal" it will convert it for you. (Kinda nifty feature they've got, incidentally.)