War card game

Discussion in 'JavaScript' started by intrinzik, Apr 9, 2007.

  1. #1
    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.
     
    intrinzik, Apr 9, 2007 IP
  2. giraph

    giraph Guest

    Messages:
    484
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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);
    }
    
    Code (markup):
    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.
     
    giraph, Apr 9, 2007 IP