diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index ff54699..b648de5 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -66,10 +66,13 @@ int userInputBJ(){ // Chance für 10 ist 4 Mal höher als für den Rest // 1 = Ass int getRandCard(int offset){ - srand(time(NULL) + offset); + int randomCard; + srand(time(NULL)); - int randomCard = rand() % ANZ_MOEGLICHE_KARTEN; - randomCard++; + for(int i = 0; i < offset; i++){ + + randomCard = (rand() % ANZ_MOEGLICHE_KARTEN) + 1; + } // 11, 12, 13 = Bube, Dame, König haben den Wert 10 if(randomCard > 10){ @@ -147,7 +150,7 @@ int playBJ(int bet, int balance){ } printf("Dealer Cards Total: %d\n", dealerCardsTotal); - if(dealerCardsTotal >= 17 && dealerCardsTotal < 21){ + if(dealerCardsTotal >= 17 && dealerCardsTotal <= 21){ if(calculateIfYouWon(userCardsTotal, dealerCardsTotal)){ winnings = calculateWinnings(false, bet); } @@ -215,6 +218,7 @@ int calculateCardsTotal(int cardsArray[], int len){ } if(aceFound && sum + cardsArray[i] > 21){ sum -= 10; + aceFound = false; } sum += cardsArray[i]; }