Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


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?
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now