I'm attempting to have a loop deal out cards in the style of Euchre (3/2/3/2). This loop is just for the first 10 right now, but it gets stuck in the first else/if statement, and deals the last 7 cards out to "Partner". Below is the code and the console outputs.
var Deck = ["h9", "h10", "hJack", "hQueen", "hKing", "hAce", "c9", "c10", "cJack", "cQueen", "cKing", "cAce", "s9", "s10", "sJack", "sQueen", "sKing", "sAce", "d9", "d10", "dJack", "dQueen", "dKing", "dAce"];
var Player = ["a", "b", "c", "d", "e"];
var AI1 = ["a", "b", "c", "d", "e"];
var Partner = ["a", "b", "c", "d", "e"];
var AI2 = ["a", "b", "c", "d", "e"];
function PlayerDeal() {
for(var y = 0; y < 10; y++)
{
var z = "";
var pleasegodno = 0;
console.log(y);
if(y < 3)
{
pleasegodno = randomNumber(0, Deck.length);
z = Deck[pleasegodno];
removeItem(AI1,0);
appendItem(AI1,z);
removeItem(Deck, pleasegodno);
console.log("Dealt card " + y + " is: " + z + "(AI1)");
}
else if(2 < y <5)
{
pleasegodno = randomNumber(0, Deck.length);
z = Deck[pleasegodno];
removeItem(Partner,0);
appendItem(Partner,z);
removeItem(Deck, pleasegodno);
console.log("Dealt card " + y + " is: " + z + "(Partner)");
}
else if(4 < y < 8)
{
pleasegodno = randomNumber(0, Deck.length);
z = Deck[pleasegodno];
removeItem(AI2,0);
appendItem(AI2,z);
removeItem(Deck, pleasegodno);
console.log("Dealt card " + y + " is: " + z + "(AI2)");
}
else if(7 < y < 10)
{
pleasegodno = randomNumber(0, Deck.length);
z = Deck[pleasegodno];
removeItem(Player,0);
appendItem(Player,z);
removeItem(Deck, pleasegodno);
console.log("Dealt card " + y + " is: " + z + "(Player)");
}
}
}
Console output is the following:
0
"Dealt card 0 is: d9(AI1)"
1
"Dealt card 1 is: cJack(AI1)"
2
"Dealt card 2 is: h10(AI1)"
3
"Dealt card 3 is: cKing(Partner)"
4
"Dealt card 4 is: hAce(Partner)"
5
"Dealt card 5 is: sQueen(Partner)"
6
"Dealt card 6 is: c9(Partner)"
7
"Dealt card 7 is: hJack(Partner)"
8
"Dealt card 8 is: hQueen(Partner)"
9
"Dealt card 9 is: hKing(Partner)"
Aucun commentaire:
Enregistrer un commentaire