I need to check for certain conditions in the code of a game I’m trying to finish. It’s a blackjack like game where you can hit a new card if your previous one is not revealed even if you’re over the total, but I need to set a condition so that one cannot ask for a card if the value of the visible cards is over the maximum score.
I solved the first situation where I am only going to have three cards dealt like so:
function dealFirstCard() {
if ((!notRevealed[0] && !notRevealed[1]) && (card0 +card1 > 7.5)){
showDealerHand();
gotoAndPlay(“Done”);
} else {
dealCard(playerHand);
showCards2();
}
}
but I would like to know if the switch form could be used when dealing the next card, so I could break the function when the condition was met.
with else it would look like this:
function dealSecondCard() {
if ((!notRevealed[0] && !notRevealed[1] && notRevealed[2]) && (card0+card1+card2> 7.5)){
showDealerHand();
gotoAndPlay(“Done”);
} else if ((!notRevealed[0] && !notRevealed[1]) && (card0+card1> 7.5)){
showDealerHand();
gotoAndPlay(“Done”);
} else if ((!notRevealed[0] && !notRevealed[2]) && (card0+card2> 7.5)){
showDealerHand();
gotoAndPlay(“Done”);
} else if ((!notRevealed[1] && !notRevealed[2]) && (card1+card2> 7.5)){
showDealerHand();
gotoAndPlay(“Done”);
} else {
dealCard(playerHand);
showCards2();
}
}
thanks