Wordpress Theme - Lyrics - Song Lyrics A to Z - Debt Consolidation - Wordpress Themes

PDA

View Full Version : War card game


intrinzik
Apr 9th 2007, 6:53 pm
Could anyone either point in the way of a tutorial about how to create the card game war, or if anyone is willing to do it for me i would pay you. I have some code written but ive reached a dead end and no longer have time to do it.

Any help would be appreciated.

giraph
Apr 9th 2007, 8:46 pm
Well what part are you stuck on? Seems the strategy I would take is.

Create a deck of 52 cards, and deal them out to two people (arrays).

while(player1.length > 0 && player2.length > 0)
{
if(player1[0] > player2[0])
{
player1.splice(player1.length, 0, player1[0], player2[0]);
player2.splice(0, 0, player2[0]);
}
else
{
//opposite logic
}
player2.splice(0, 1);
player1.splice(0, 1);
}


Just wrote that off my head because I don't really have time right now, but if you can tell any specific problem you're having feel free to update this thread.