|
@ -73,6 +73,8 @@ int getRandCard(){ |
|
|
|
|
|
|
|
|
int playBJ(int bet, int balance){ |
|
|
int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
|
|
|
|
int winnings = 0; |
|
|
|
|
|
|
|
|
int *computerCardArray = (int*) malloc(10 * sizeof(int)); |
|
|
int *computerCardArray = (int*) malloc(10 * sizeof(int)); |
|
|
|
|
|
|
|
|
if(computerCardArray){ |
|
|
if(computerCardArray){ |
|
@ -88,7 +90,10 @@ int playBJ(int bet, int balance){ |
|
|
userCardArray[1] = getRandCard(); |
|
|
userCardArray[1] = getRandCard(); |
|
|
printf("user rand card: %d\n", userCardArray[1]); |
|
|
printf("user rand card: %d\n", userCardArray[1]); |
|
|
|
|
|
|
|
|
checkForBlackjack(userCardArray); |
|
|
|
|
|
|
|
|
if(checkForBlackjack(userCardArray)){ |
|
|
|
|
|
winnings = calculateWinnings(true, bet); |
|
|
|
|
|
return balance + winnings; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(userCardArray); |
|
|
free(userCardArray); |
|
@ -121,4 +126,11 @@ int calculateCardsTotal(int cardsArray[], int len){ |
|
|
sum += cardsArray[i]; |
|
|
sum += cardsArray[i]; |
|
|
} |
|
|
} |
|
|
return sum; |
|
|
return sum; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int calculateWinnings(bool blackjack, int bet){ |
|
|
|
|
|
if(blackjack){ |
|
|
|
|
|
return 3 * bet; |
|
|
|
|
|
} |
|
|
|
|
|
return 2 * bet; |
|
|
} |
|
|
} |