modifications dans les règles et pour la somme à chaque tour
This commit is contained in:
parent
26c59b07ba
commit
950637358c
1 changed files with 23 additions and 22 deletions
45
blackjack.c
45
blackjack.c
|
@ -100,7 +100,7 @@ int victory(int sum) {
|
||||||
|
|
||||||
void draw_card(int value, char couleur) {
|
void draw_card(int value, char couleur) {
|
||||||
if (value == 1 || value == 14 || value == 27 || value == 40) {
|
if (value == 1 || value == 14 || value == 27 || value == 40) {
|
||||||
printf(" ------------\n");
|
printf(" -----------\n");
|
||||||
printf("| A %c |\n",couleur);
|
printf("| A %c |\n",couleur);
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
|
@ -108,9 +108,9 @@ void draw_card(int value, char couleur) {
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| A %c|\n",couleur);
|
printf("| A %c|\n",couleur);
|
||||||
printf(" ------------\n\n");
|
printf(" -----------\n\n");
|
||||||
} else if (value == 11 || value == 24 || value == 37 || value == 50) {
|
} else if (value == 11 || value == 24 || value == 37 || value == 50) {
|
||||||
printf(" ------------\n");
|
printf(" -----------\n");
|
||||||
printf("| J %c |\n",couleur);
|
printf("| J %c |\n",couleur);
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
|
@ -118,9 +118,9 @@ void draw_card(int value, char couleur) {
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| J %c|\n",couleur);
|
printf("| J %c|\n",couleur);
|
||||||
printf(" ------------\n\n");
|
printf(" -----------\n\n");
|
||||||
} else if (value == 12 || value == 25 || value == 38 || value == 51) {
|
} else if (value == 12 || value == 25 || value == 38 || value == 51) {
|
||||||
printf(" ------------\n");
|
printf(" -----------\n");
|
||||||
printf("| Q %c |\n",couleur);
|
printf("| Q %c |\n",couleur);
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
|
@ -128,9 +128,9 @@ void draw_card(int value, char couleur) {
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| Q %c|\n",couleur);
|
printf("| Q %c|\n",couleur);
|
||||||
printf(" ------------\n\n");
|
printf(" -----------\n\n");
|
||||||
} else if (value == 13 || value == 26 || value == 39 || value == 52) {
|
} else if (value == 13 || value == 26 || value == 39 || value == 52) {
|
||||||
printf(" ------------\n");
|
printf(" -----------\n");
|
||||||
printf("| K %c |\n",couleur);
|
printf("| K %c |\n",couleur);
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
|
@ -138,7 +138,7 @@ void draw_card(int value, char couleur) {
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| |\n");
|
printf("| |\n");
|
||||||
printf("| K %c|\n",couleur);
|
printf("| K %c|\n",couleur);
|
||||||
printf(" ------------\n\n");
|
printf(" -----------\n\n");
|
||||||
} else {
|
} else {
|
||||||
printf(" ------------\n");
|
printf(" ------------\n");
|
||||||
printf("|%2d %c |\n",real_value(value),couleur);
|
printf("|%2d %c |\n",real_value(value),couleur);
|
||||||
|
@ -167,7 +167,9 @@ int main() {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
printf(" -> You must have a final score greater than the dealer's one.\n");
|
printf(" -> You must have a final score greater than the dealer's one.\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
printf(" -> If the dealer's final score is greater than 21, everyone who has a score less or equal to 21 wins the game.\n\n");
|
printf(" -> If the dealer's final score is greater than 21, everyone who has a score less or equal to 21 wins the game.\n");
|
||||||
|
sleep(1);
|
||||||
|
printf(" -> As' cards are equal to 1 point in every situation.\n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
waitUser();
|
waitUser();
|
||||||
clearUserScreen();
|
clearUserScreen();
|
||||||
|
@ -179,8 +181,6 @@ int main() {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
printf("1\n");
|
printf("1\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
printf("GO!");
|
|
||||||
sleep(1);
|
|
||||||
clearUserScreen();
|
clearUserScreen();
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
@ -191,13 +191,14 @@ int main() {
|
||||||
cards[dealer[0]-1] = 0;
|
cards[dealer[0]-1] = 0;
|
||||||
cards[dealer[1]-1] = 0;
|
cards[dealer[1]-1] = 0;
|
||||||
|
|
||||||
|
printf("-- DEALER TURNS HIS CARDS UP --\n\n");
|
||||||
|
sleep(2);
|
||||||
|
|
||||||
printf("Dealer first card is : \n\n");
|
printf("Dealer first card is : \n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
draw_card(dealer[0],real_color(dealer[0]));
|
draw_card(dealer[0],real_color(dealer[0]));
|
||||||
sleep(1);
|
sleep(1);
|
||||||
printf("Dealer second card is : ");
|
printf("Dealer second card is : hidden card\n\n");
|
||||||
sleep(1);
|
|
||||||
printf("hidden card\n\n");
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
waitUser();
|
waitUser();
|
||||||
clearUserScreen();
|
clearUserScreen();
|
||||||
|
@ -291,13 +292,14 @@ int main() {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
printf("Your next card is : \n\n");
|
printf("Your next card is : \n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
draw_card(card_acc,real_color(card_acc));
|
draw_card(card_acc,real_color(card_acc));
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if (victory(sum1) == 1) {
|
if (victory(sum1) == 1) {
|
||||||
printf(" -> Your final cards are : <-\n\n");
|
printf("-> Your final cards are : <-\n\n");
|
||||||
for (int a = 0; player1[a] != 0; ++a) {
|
for (int a = 0; player1[a] != 0; ++a) {
|
||||||
draw_card(player1[a],real_color(player1[a]));
|
draw_card(player1[a],real_color(player1[a]));
|
||||||
}
|
}
|
||||||
|
@ -306,15 +308,14 @@ int main() {
|
||||||
sum1 = 0;
|
sum1 = 0;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
printf("Your current score is : %d\n",sum1);
|
||||||
printf("Would you like to turn up more cards ? Enter '1' for YES or '2' for NO : \n");
|
printf("Would you like to turn up more cards ? Enter '1' for YES or '2' for NO : \n");
|
||||||
scanf("%d", &res_p1);
|
scanf("%d", &res_p1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sum1 != 0) {
|
if (sum1 != 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("You decided to stop turning up new cards. Your final score is : ");
|
printf("You decided to stop turning up new cards. Your final score is : %d\n",sum1);
|
||||||
sleep(1);
|
|
||||||
printf("%d\n",sum1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -358,13 +359,14 @@ int main() {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
printf("Your next card is : \n\n");
|
printf("Your next card is : \n\n");
|
||||||
sleep(1);
|
sleep(1);
|
||||||
draw_card(card_acc,real_color(card_acc));
|
draw_card(card_acc,real_color(card_acc));
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
if (victory(sum2) == 1) {
|
if (victory(sum2) == 1) {
|
||||||
printf(" -> Your final cards are : <-\n\n");
|
printf("-> Your final cards are : <-\n\n");
|
||||||
for (int b = 0; player2[b] != 0; ++b) {
|
for (int b = 0; player2[b] != 0; ++b) {
|
||||||
draw_card(player2[b],real_color(player2[b]));
|
draw_card(player2[b],real_color(player2[b]));
|
||||||
}
|
}
|
||||||
|
@ -373,15 +375,14 @@ int main() {
|
||||||
sum2 = 0;
|
sum2 = 0;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
printf("Your current score is : %d\n",sum2);
|
||||||
printf("Would you like to turn up more cards ? Enter '1' for YES or '2' for NO : \n");
|
printf("Would you like to turn up more cards ? Enter '1' for YES or '2' for NO : \n");
|
||||||
scanf("%d", &res_p2);
|
scanf("%d", &res_p2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sum2 != 0) {
|
if (sum2 != 0) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("You decided to stop turning up new cards. Your final score is : ");
|
printf("You decided to stop turning up new cards. Your final score is : %d\n",sum2);
|
||||||
sleep(1);
|
|
||||||
printf("%d\n",sum2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
Reference in a new issue