From 632d4b332cb95f7a216a7c8aa17a48cca78814e0 Mon Sep 17 00:00:00 2001 From: Lea Date: Sun, 7 Dec 2025 11:46:20 -0500 Subject: [PATCH] =?UTF-8?q?maintenant=20tout=20marche,=20la=20validation?= =?UTF-8?q?=20pour=20la=20diagonale=20de=201=203=20=C3=A0=203=201=20foncti?= =?UTF-8?q?onne=20enfin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe/fonctions.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index 52d9f9d..989e857 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -28,7 +28,7 @@ char carre = 219, choix; //À faire : égalité et entrer de coordonnée //Fichiers -void ouvrirFichier(std::fstream & monFlux, std::string nomFichier) { +void ouvrirFichier(std::fstream& monFlux, std::string nomFichier) { monFlux.open(nomFichier, ios::in); if (!monFlux) //On vérifie si le flux est "faux"/non fonctionnel. { @@ -38,7 +38,7 @@ void ouvrirFichier(std::fstream & monFlux, std::string nomFichier) { } } -void fermerFichier(std::fstream & monFlux) { +void fermerFichier(std::fstream& monFlux) { monFlux.close(); } @@ -63,7 +63,7 @@ void afficherMenu(char& choix) { cout << endl; } -void afficherImageMenu(std::fstream & monFlux) { +void afficherImageMenu(std::fstream& monFlux) { int repet = 0; if (monFlux) { while (!monFlux.eof()) { @@ -247,11 +247,12 @@ bool verifFinMatch(std::string grid[][LARGTIC], int compteur) { // Valide diagonale 02, 11, 20 fin = true; for (int i = 2; i > 0; i--) { - if (grid[i][i] == "") { + if (grid[i][2-i] == "") { fin = false; } else { - fin = fin && (grid[i][i] == grid[i - 1][i - 1]); + fin = fin && (grid[i][2 - i] == grid[2-i][i]); + cout << "Vérification de " << i << "," << 2 - i << " et " << 2 - i << "," << i << endl; } } @@ -276,7 +277,7 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { } } - else if (nbJoueurs == 2){ + else if (nbJoueurs == 2) { if (gagnant == 1) { cout << "\n\nJoueur 1 a gagne la partie!"; } @@ -419,6 +420,7 @@ void changerLeTheme() { system("cls"); cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl; do { + system("cls"); cout << endl << "Options des styles: " << "\n\n-------------------------------------" << "\nA) Par defaut" @@ -445,7 +447,7 @@ void changerLeTheme() { style = "themes/themeDefaut.txt"; cout << "\nLe theme par defaut sera quand meme choisi. \n"; } - + system("PAUSE>nul"); break; case 'B': @@ -464,6 +466,7 @@ void changerLeTheme() { style = "themes/themeDefaut.txt"; cout << "\nLe theme par defaut sera choisi.\n"; } + system("PAUSE>nul"); break; case 'C': @@ -482,6 +485,7 @@ void changerLeTheme() { style = "themes/themeDefaut.txt"; cout << "\nLe theme par defaut sera choisi.\n"; } + system("PAUSE>nul"); break; case 'D': @@ -500,6 +504,7 @@ void changerLeTheme() { style = "themes/themeDefaut.txt"; cout << "\nLe theme par defaut sera choisi.\n"; } + system("PAUSE>nul"); break; case 'E': @@ -518,6 +523,7 @@ void changerLeTheme() { style = "themes/themeDefaut.txt"; cout << "\nLe theme par defaut sera choisi.\n"; } + system("PAUSE>nul"); break; case 'Q': @@ -526,6 +532,7 @@ void changerLeTheme() { default: cout << "\n\nChoisir une option valide. \n"; + system("PAUSE>nul"); break; } } while (choix != 'Q');