Page 1 of 1

Attempting to make a blackjack game

PostPosted: Sun Jun 22, 2014 1:40 am
by mochizmo
Hi everyone. I'm specifically having trouble with getting aces to total 1 or 11. Anyone with a sample capx on blackjack? I cant find anything searching for it. Thanks!

Re: Attempting to make a blackjack game

PostPosted: Sun Jun 22, 2014 10:22 am
by monitz87
You could try something like having the Aces to total 11 by default and then using the conditional expression. Let's say you already have the summed total in a local variable called CurrentTotal, and you're just missing the Ace (which you can simply leave for last by ordering cards in the player's hand by ascending value.

You could do something like

CurrentTotal = CurrentTotal + Ace.Value > 21 ? CurrentTotal + 1 : CurrentTotal + Ace.Value

Re: Attempting to make a blackjack game

PostPosted: Tue Jun 24, 2014 2:33 am
by mochizmo
Thank you monitz, it worked!