|
@ -117,10 +117,10 @@ int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
|
userCardsTotal = calculateCardsTotal(userCardsArray, i); |
|
|
userCardsTotal = calculateCardsTotal(userCardsArray, i); |
|
|
|
|
|
|
|
|
printf("Your Cards Total : %d\n", userCardsTotal); |
|
|
|
|
|
|
|
|
printf("Your Cards Total: %d\n\n", userCardsTotal); |
|
|
|
|
|
|
|
|
if(userCardsTotal > 21){ |
|
|
if(userCardsTotal > 21){ |
|
|
printf("BUST\n"); |
|
|
|
|
|
|
|
|
printf("YOU BUST\n\n"); |
|
|
|
|
|
|
|
|
free(userCardsArray); |
|
|
free(userCardsArray); |
|
|
free(dealerCardsArray); |
|
|
free(dealerCardsArray); |
|
@ -129,7 +129,7 @@ int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
|
if(hit()){ |
|
|
if(hit()){ |
|
|
userCardsArray[i] = getRandCard(i); |
|
|
userCardsArray[i] = getRandCard(i); |
|
|
printf("new card: %d\n", userCardsArray[i]); |
|
|
|
|
|
|
|
|
printf("Your new card: %d\n", userCardsArray[i]); |
|
|
} else{ |
|
|
} else{ |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -142,10 +142,10 @@ int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
|
if(dealerCardsTotal < 17){ |
|
|
if(dealerCardsTotal < 17){ |
|
|
dealerCardsArray[i] = getRandCard(i); |
|
|
dealerCardsArray[i] = getRandCard(i); |
|
|
printf("Computer Card: %d\n", dealerCardsArray[i]); |
|
|
|
|
|
|
|
|
printf("Dealer Card: %d\n", dealerCardsArray[i]); |
|
|
dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i + 1); |
|
|
dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i + 1); |
|
|
} |
|
|
} |
|
|
printf("Computer Cards Total: %d\n", dealerCardsTotal); |
|
|
|
|
|
|
|
|
printf("Dealer Cards Total: %d\n", dealerCardsTotal); |
|
|
|
|
|
|
|
|
if(dealerCardsTotal >= 17 && dealerCardsTotal < 21){ |
|
|
if(dealerCardsTotal >= 17 && dealerCardsTotal < 21){ |
|
|
if(calculateIfYouWon(userCardsTotal, dealerCardsTotal)){ |
|
|
if(calculateIfYouWon(userCardsTotal, dealerCardsTotal)){ |
|
@ -155,7 +155,7 @@ int playBJ(int bet, int balance){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(dealerCardsTotal > 21){ |
|
|
if(dealerCardsTotal > 21){ |
|
|
printf("COMPUTER BUST\n"); |
|
|
|
|
|
|
|
|
printf("DEALER BUST\n\n"); |
|
|
winnings = calculateWinnings(false, bet); |
|
|
winnings = calculateWinnings(false, bet); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -178,7 +178,7 @@ int playBJ(int bet, int balance){ |
|
|
|
|
|
|
|
|
bool checkForBlackjack(int userCardArray[]){ |
|
|
bool checkForBlackjack(int userCardArray[]){ |
|
|
if(userCardArray[0] + userCardArray[1] == 21){ |
|
|
if(userCardArray[0] + userCardArray[1] == 21){ |
|
|
printf("BLACKJACK!\n"); |
|
|
|
|
|
|
|
|
printf("BLACKJACK!\n\n"); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
@ -191,10 +191,10 @@ bool hit(){ |
|
|
scanf("%d", &answer); |
|
|
scanf("%d", &answer); |
|
|
|
|
|
|
|
|
if(answer != 1){ |
|
|
if(answer != 1){ |
|
|
printf("stand.\n"); |
|
|
|
|
|
|
|
|
printf("You stand.\n\n"); |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
printf("hit.\n"); |
|
|
|
|
|
|
|
|
printf("You hit.\n\n"); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|