|
|
@ -8,14 +8,20 @@ int blackjack(){ |
|
|
|
|
|
|
|
printf("Welcome to Blackjack \n\n"); |
|
|
|
|
|
|
|
bool exit = false; |
|
|
|
bool *exitPtr = &exit; |
|
|
|
int balance = getBalanceBJ(); |
|
|
|
|
|
|
|
while(balance > 0){ |
|
|
|
printf("Aktuelles Guthaben: %d\n", balance); |
|
|
|
int bet = getBetBJ(balance); |
|
|
|
int bet = getBetBJ(balance, exitPtr); |
|
|
|
if(exit) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
balance -= bet; |
|
|
|
|
|
|
|
playBJ(bet, balance); |
|
|
|
balance = playBJ(bet, balance); |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
@ -24,18 +30,21 @@ int blackjack(){ |
|
|
|
int getBalanceBJ(){ |
|
|
|
printf("Guthaben einwerfen: "); |
|
|
|
int balance = userInputBJ(); |
|
|
|
printf("Dein Guthaben: %d\n", balance); |
|
|
|
return balance; |
|
|
|
} |
|
|
|
|
|
|
|
int getBetBJ(int balance){ |
|
|
|
int getBetBJ(int balance, bool *exitPtr){ |
|
|
|
|
|
|
|
while(1){ |
|
|
|
printf("\nGib (0) ein, um Blackjack zu verlassen.\n"); |
|
|
|
printf("Wetteinsatz: "); |
|
|
|
int bet = userInputBJ(); |
|
|
|
|
|
|
|
if(bet <= balance && bet > 0){ |
|
|
|
return bet; |
|
|
|
} else if(bet == 0) { |
|
|
|
*exitPtr = true; |
|
|
|
break; |
|
|
|
} else { |
|
|
|
printf("Ungueltige Eingabe!\n"); |
|
|
|
} |
|
|
|