|
|
@ -2,6 +2,7 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <stdbool.h> |
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
int blackjack(){ |
|
|
|
|
|
|
@ -65,7 +66,8 @@ int userInputBJ(){ |
|
|
|
// Liefert eine Zufallszahl zwischen 1 und 10 |
|
|
|
// Chance für 10 ist 4 Mal höher als für den Rest |
|
|
|
// 1 = Ass |
|
|
|
int getRandCard(){ |
|
|
|
int getRandCard(int offset){ |
|
|
|
srand(time(NULL) + offset); |
|
|
|
|
|
|
|
int r = rand() % 13; |
|
|
|
r++; |
|
|
@ -91,16 +93,16 @@ int playBJ(int bet, int balance){ |
|
|
|
int *dealerCardsArray = (int*) malloc(10 * sizeof(int)); |
|
|
|
|
|
|
|
if(dealerCardsArray){ |
|
|
|
dealerCardsArray[0] = getRandCard(); |
|
|
|
dealerCardsArray[0] = getRandCard(0); |
|
|
|
printf("computer rand card: %d\n", dealerCardsArray[0]); |
|
|
|
|
|
|
|
int *userCardsArray = (int*) malloc(10 * sizeof(int)); |
|
|
|
|
|
|
|
if(userCardsArray){ |
|
|
|
|
|
|
|
userCardsArray[0] = getRandCard(); |
|
|
|
userCardsArray[0] = getRandCard(1); |
|
|
|
printf("user rand card: %d\n", userCardsArray[0]); |
|
|
|
userCardsArray[1] = getRandCard(); |
|
|
|
userCardsArray[1] = getRandCard(2); |
|
|
|
printf("user rand card: %d\n", userCardsArray[1]); |
|
|
|
|
|
|
|
if(checkForBlackjack(userCardsArray)){ |
|
|
@ -125,7 +127,7 @@ int playBJ(int bet, int balance){ |
|
|
|
} |
|
|
|
|
|
|
|
if(hit()){ |
|
|
|
userCardsArray[i] = getRandCard(); |
|
|
|
userCardsArray[i] = getRandCard(i); |
|
|
|
printf("new card: %d\n", userCardsArray[i]); |
|
|
|
} else{ |
|
|
|
break; |
|
|
@ -138,7 +140,7 @@ int playBJ(int bet, int balance){ |
|
|
|
dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i); |
|
|
|
|
|
|
|
if(dealerCardsTotal < 17){ |
|
|
|
dealerCardsArray[i] = getRandCard(); |
|
|
|
dealerCardsArray[i] = getRandCard(i); |
|
|
|
printf("Computer Card: %d\n", dealerCardsArray[i]); |
|
|
|
dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i + 1); |
|
|
|
} |
|
|
|