|
|
@ -222,19 +222,21 @@ bool calculateIfYouWon(int userCardsTotal, int computerCardsTotal){ |
|
|
|
} |
|
|
|
|
|
|
|
int calculateCardsTotal(int cardsArray[], int len){ |
|
|
|
int sum = 0; |
|
|
|
bool aceFound = false; |
|
|
|
int total = 0; |
|
|
|
bool acesFound = false; |
|
|
|
for(int i = 0; i < len; i++){ |
|
|
|
if(cardsArray[i] == 11){ |
|
|
|
aceFound = true; |
|
|
|
acesFound = true; |
|
|
|
} |
|
|
|
if(aceFound && sum + cardsArray[i] > 21){ |
|
|
|
sum -= 10; |
|
|
|
aceFound = false; |
|
|
|
// Wenn der total > 21, aber man hat ein Ass, dann zählt hat das Ass den Wert 1, nicht 11 |
|
|
|
if(acesFound && total + cardsArray[i] > 21){ |
|
|
|
total -= 10; |
|
|
|
// Das gleiche Ass kann nicht mehrmals den total um 10 senken |
|
|
|
acesFound = false; |
|
|
|
} |
|
|
|
sum += cardsArray[i]; |
|
|
|
total += cardsArray[i]; |
|
|
|
} |
|
|
|
return sum; |
|
|
|
return total; |
|
|
|
} |
|
|
|
|
|
|
|
int calculateWinnings(bool blackjack, int bet){ |
|
|
|