Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript help!

Name: Anonymous 2013-05-31 13:16

Could someone please help me with this javascript? I've asked just about everywhere and I've gotten no response. Why is this deal function returning undefined?

//Creates the deck as an array and logs it to the console.
Ace = 1;
deck = [0-51];
deck[0] = Ace;
deck[1] = 2;
deck[2] = 3;
deck[3] = 4;
deck[4] = 5;
deck[5] = 6;
deck[6] = 7;
deck[7] = 8;
deck[8] = 9;
deck[9] = 10;
deck[10] = 10;
deck[11] = 10;
deck[12] = 10;
deck[13] = Ace;
deck[14] = 2;
deck[15] = 3;
deck[16] = 4;
deck[17] = 5;
deck[18] = 6;
deck[19] = 7;
deck[20] = 8;
deck[21] = 9;
deck[22] = 10;
deck[23] = 10;
deck[24] = 10;
deck[25] = 10;
deck[26] = Ace;
deck[27] = 2;
deck[28] = 3;
deck[29] = 4;
deck[30] = 5;
deck[31] = 6;
deck[32] = 7;
deck[33] = 8;
deck[34] = 9;
deck[35] = 10;
deck[36] = 10;
deck[37] = 10;
deck[38] = 10;
deck[39] = Ace;
deck[40] = 2;
deck[41] = 3;
deck[42] = 4;
deck[43] = 5;
deck[44] = 6;
deck[45] = 7;
deck[46] = 8;
deck[47] = 9;
deck[48] = 10;
deck[49] = 10;
deck[50] = 10;
deck[51] = 10;
console.log(deck);
//Creates the player and bot as objects. Hit and fold are booleans where as all of the hands are numeraric values.
function player(hit, stay, card1, card2, card3, card4, card5) {
    hit = hit;
    stay = stay;
    card1 = card1;
    card2 = card2;
    card3 = card3;
    card4 = card4;
    card5 = card5;
}

function bot(hit, stay, card1, card2, card3, card4, card5) {
    hit = hit;
    stay = stay;
    card1 = card1;
    card2 = card2;
    card3 = card3;
    card4 = card4;
    card5 = card5;
}
//creates a function that shuffles the deck. This will be the first step in the while loop.
shuffle = function(list) {
  var i, j, t;
  for (i = 1; i < list.length; i++) {
    j = Math.floor(Math.random()*(1+i)); 
    if (j != i) {
      t = list[i];                       
      list[i] = list[j];
      list[j] = t;
    }}};
//This will deal a new card to either the player or bot.
deal = function(pob, val) {
    pob = deck[val];
};
//This while loop is the actual game, it calls on the functions created above in a specific order, simulating the order of operations in a game, then breaks when the game is over.
while(1) {
    shuffle(deck);
    deal(player.card1, 0);
    console.log(deck, player.card1);
    break;
}

Name: Anonymous 2013-05-31 13:25

What kind of decks do you have? Four tens?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List