Browse Source

refactoring: Konsolenausgaben etwas schoener geschrieben/formatiert

remotes/origin/stefan
fdai7472 11 months ago
parent
commit
d7a0fa4511
  1. 18
      src/main/c/Stefan/blackjack.c

18
src/main/c/Stefan/blackjack.c

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

Loading…
Cancel
Save