Intel sponsors gamedev.net search:   
Adventures in Text-modeBy Twisol      
In order of no progress to done: Red, Orange, Yellow, Blue, Light blue, Green, Light green.

Last updated 2/12/09 at 12:01 am PST

Cripes! 2.0 -- See the Class Layout

Arenamatic Code w/ cConsole


Wednesday, June 20, 2007
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?

Comments: 0 - Leave a Comment

Link



Tuesday, June 19, 2007
Um... Not much to update on actually. I got sidetracked on a more basic project.. the infamous card deck. <_< I never really got much experience with objects when I first started using them, so I thought I'd follow in the steps of a few other people I've seen around GDnet and make a card game. So, on the the update there.

Vector iterators stink. If you have two, and you erase at one of them, the other one gets invalidated! -_- I was trying to make a sort for my deck - using my own home-made algorithm - but I kept getting mysterious "iterator out of range" runetime exceptions. Debugging brought me to my deck.erase statement - or at least the area around there. Meh. At least I learned a bit about <algorithm>, cause I'm using std::sort from there instead.

That leads me into the next update-rant. For some freakish reason, std::sort won't accept list begin() and end() iterators. I honestly don't know why, but when I tried to switch to a list - you know.. to see if I could solve my original invalid iterators problem - it threw THAT at me. UGH!

But, all is well. I'm still using a vector, and I'm sticking with std::sort... pity about my algorithm. I've got card types and suits set up, a constructor that lets you specify whether to have jokers or not, a DeckSize() function for the current size of the deck (excluding drawn cards), a TotalSize() function (it gives you the entire decksize, including drawn cards, which aren't actually removed from the vector), and Sort() and Shuffle() functions (which automatically return the deck to its fully un-drawn state, where TotalSize() and DeckSize() would be the same).

I was originally planning on having CardDeck be able to act as a hand too, but it seems a bit too complex for one class, so I'll likely remove Sort() and use it for CardHand. After I finish that, I'll be making a basic War card game. :D

So, summary: War going well, Harbinger on hold.

P.S. Did I mention I got Apache, MediaWiki, mySQL, and PHP5 on my iPod?

Comments: 0 - Leave a Comment

Link


All times are ET (US)

 
S
M
T
W
T
F
S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30

OPTIONS
Track this Journal

 RSS 

ARCHIVES
August, 2009
July, 2009
March, 2009
February, 2009
December, 2008
November, 2008
October, 2008
August, 2008
July, 2008
June, 2008
May, 2008
April, 2008
November, 2007
July, 2007
June, 2007
May, 2007
April, 2007
March, 2007
February, 2007
December, 2006
October, 2006
September, 2006
July, 2006
May, 2006
April, 2006