ajout de la compatibilité sous linux

This commit is contained in:
Mylloon 2021-03-24 20:11:44 +01:00
parent ceb026398c
commit 6bd8ad1627

View file

@ -1,6 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
// linux
#include <curses.h> // fonction de conio.h en linux
#include <unistd.h> // fonction sleep
#include <time.h> // fonction time
// windows
// #include <conio.h>
int cards[53] = {1,2,3,4,5,6,7,8,9,10,11,12,13,
14,15,16,17,18,19,20,21,22,23,24,25,26,
@ -122,8 +129,13 @@ int main() {
int res_p2, sum2 = 0;
printf("Welcome to BLACKJACK !\n");
printf("Press any key to continue...\n\n");
getch();
// linux
printf("Press ENTER to continue...\n\n");
getchar();
// windows
// printf("Press any key to continue...\n\n");
// getch();
printf(" -> Your goal is to score exactly 21 points or the nearest possible to 21.\n");
sleep(1);
@ -133,10 +145,16 @@ int main() {
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");
sleep(1);
// linux
printf("Are you ready ?\n\n");
printf("Press any key to continue...\n");
getch();
system("cls");
printf("Press ENTER to continue...\n\n");
getchar();
system("clear");
// windows
// printf("Press any key to continue...\n\n");
// getch();
//system("cls");
printf("The game begins in...\n");
printf("3\n");
@ -147,7 +165,11 @@ int main() {
sleep(1);
printf("GO!");
sleep(1);
system("cls");
// linux
system("clear");
// windows
// system("cls");
srand(time(NULL));
dealer[0] = (rand() % 52) + 1;
@ -165,9 +187,15 @@ int main() {
sleep(1);
printf("hidden card\n\n");
sleep(1);
printf("Press any key to continue...\n");
getch();
system("cls");
// linux
printf("Press ENTER to continue...\n\n");
getchar();
system("clear");
// windows
// printf("Press any key to continue...\n\n");
// getch();
// system("cls");
printf("Each player will now receive their two first initial cards :\n\n");
sleep(2);
@ -228,9 +256,15 @@ int main() {
sleep(1);
draw_card(player2[1],real_color(player2[1]));
printf("Press any key to continue...");
getch();
system("cls");
// linux
printf("Press ENTER to continue...\n\n");
getchar();
system("clear");
// windows
// printf("Press any key to continue...\n\n");
// getch();
// system("cls");
printf("Player 1, you can now choose either to turn more cards up or to keep your current values :\n\n");
sleep(2);
@ -293,9 +327,15 @@ int main() {
printf("\n");
printf("You decided to keep your current values. You can no longer have more cards. Your final score is : %d\n", sum1);
}
printf("Press any key to continue...");
getch();
system("cls");
// linux
printf("Press ENTER to continue...\n\n");
getchar();
system("clear");
// windows
// printf("Press any key to continue...\n\n");
// getch();
// system("cls");
i = 0;
acc = 2;
@ -361,9 +401,15 @@ int main() {
printf("\n");
printf("You decided to keep your current values. You can no longer have more cards. Your final score is : %d\n", sum2);
}
printf("Press any key to continue...");
getch();
system("cls");
// linux
printf("Press ENTER to continue...\n\n");
getchar();
system("clear");
// windows
// printf("Press any key to continue...\n\n");
// getch();
// system("cls");
acc = 2;
@ -463,8 +509,13 @@ int main() {
}
}
printf("Press any key to continue...");
getch();
// linux
printf("Press ENTER to continue...\n\n");
getchar();
// windows
// printf("Press any key to continue...\n\n");
// getch();
return 0;
}
}