Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Need some added help perfecting a game

Need some added help perfecting a game

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Dralnu   USA  (277 posts)  Bio
Date Thu 09 Jun 2005 12:40 AM (UTC)
Message
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.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #1 on Thu 09 Jun 2005 03:08 AM (UTC)
Message
That should work fine as is so long as you make it a global array.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #2 on Thu 09 Jun 2005 05:39 PM (UTC)
Message
thanks. I'll post again later if I need anymore help
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Wed 15 Jun 2005 09:43 AM (UTC)
Message
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.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Dralnu   USA  (277 posts)  Bio
Date Reply #4 on Wed 15 Jun 2005 07:46 PM (UTC)
Message
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.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Wed 15 Jun 2005 10:52 PM (UTC)
Message
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.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


19,354 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.