diff --git a/TicTacToe/0 b/TicTacToe/0 index d7619da..4588032 100644 --- a/TicTacToe/0 +++ b/TicTacToe/0 @@ -1 +1 @@ -Appuyez sur une touche pour continuer... \ No newline at end of file +Appuyez sur une touche pour continuer... diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index 7ef2ec4..0a69c2b 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -17,6 +17,7 @@ using namespace std; extern const int LARGTIC; const string ICONJ1 = { "X" }; const string ICONJ2 = { "O" }; +int codeConsole = 0; fstream monFlux; HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE); @@ -40,6 +41,7 @@ void fermerFichier(std::fstream& monFlux) { //Menu void afficherMenu(char& choix) { system("cls"); + codeConsole = GetConsoleOutputCP(); //T I C T A C T O E ouvrirFichier(monFlux, "menuTitre.txt"); afficherImageMenu(monFlux); @@ -88,6 +90,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) { string emoteUp, emoteLine, emoteDown; + // Faire une fonction pour retenir le thème sélectionné par le joueur!!!! ouvrirFichier(monFlux, "themes/themeSea.txt"); if (monFlux) { while (!monFlux.eof()) { @@ -102,6 +105,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) { } fermerFichier(monFlux); + // Lignes de code pour faire afficher le Tic Tac Toe une fois que les symboles ont été ajoutés cout << " "; for (int i = 0; i < LARGTIC; i++) { cout << " " << i + 1 << " "; @@ -147,7 +151,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) { } } cout << endl; - + SetConsoleOutputCP(codeConsole); } void tourJoueur(string grid[][LARGTIC], int joueur) { @@ -171,7 +175,7 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { } bool verifFinMatch(std::string grid[][LARGTIC]) { - bool fin = true; + bool fin = false; // Valide horizontales for (int i = 0; i < 2; i++) { fin = true; @@ -202,6 +206,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) { } // Valide diagonale 02, 11, 20 + fin = true; for (int i = 2; i > 0; i--) { fin = fin && grid[i][i] == grid[i - 1][i - 1]; if (fin == true) { @@ -217,20 +222,24 @@ void jeuUnJoueur(string grid[][LARGTIC]) { do { tourJoueur(grid, 1); + //fin = verifFinMatch(grid); tourOrdi(grid); system("PAUSE>0"); fin = verifFinMatch(grid); - } while (fin = true); + } while (fin != true); } void tourOrdi(string grid[][LARGTIC]) { - int vertical = rand() % (3); - int horizontal = rand() % (3); + int vertical; + int horizontal; cout << "\n\nTour de l'ordinateur" << endl; - afficherImageTableau(grid); - + do { + vertical = rand() % (3); + horizontal = rand() % (3); + } while (grid[vertical][horizontal] != " "); grid[vertical][horizontal] = ICONJ2; + afficherImageTableau(grid); } //2 joueurs @@ -242,6 +251,6 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { tourJoueur(grid, 1); tourJoueur(grid, 2); fin = verifFinMatch(grid); - // la condition doit être une série de 3 chiffres - } while (fin = true); + // la condition doit être une série de 3 symboles pareil + } while (fin != true); } \ No newline at end of file