🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

War!

Published June 20, 2007
Advertisement
War is coming along well. I have the basic Card and CardDeck classes, with CardHand on its way. I'm also working on the War class, which will handle most of the details of the gameplay. When it's used, you simply create an instance of War, specifying with a bool whether to include Jokers or not, and then run a while loop that iterates over War::Fight() and War::Draw().

Making the two steps of the game into two functions allows the user to do additional stuff between the draw and the fight, such as wait for user input before doing either. Also, a built-in safeguard prevents more than one draw in a row, as well as more than one fight in a row. As well, Fight() handles the details of the "War round". Draw() returns whether the cards were drawn at all (in case someone's deck is out), and Fight() returns the result of the battle (1 if you won, 2 if the opponent won, and 0 if it was a war).

How does the user figure out whether there will be a War round before it occurs? The GetPCard() and GetOCard() methods return the Card that the Player or the Opponent, respectively, will be playing next turn. They returns BAD_SUIT, BAD_VALUE cards if there was no Draw() after the last Fight(), or if the one player has no cards left. This effectively also lets the user know whether one player has won, as there will never be a winning game with both players having empty decks, nor will there be a case where only one deck is drawn from. (I'm sure I could implement a helper Won() function if I think it's required...)

I'm debating over whether to add GetPSize and GetOSize methods, because that would take away from the value of the Get[X]Card methods being able to tell you if there was a winner, although it would make it easier.

Anyways, thoughts on my progress?
Previous Entry Harbinger Update
Next Entry cConsole
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement