From 5597f5248d02148c9dbefbde8217a7a206c112f5 Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 26 Nov 2025 11:22:17 -0500 Subject: [PATCH 1/2] =?UTF-8?q?DERNIER=20COMMIT=20DE=20LA=20JOURN=C3=89E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe/0 | 2 +- TicTacToe/fonctions.cpp | 35 ++++++++++++-------------------- TicTacToe/main.cpp | 5 ----- TicTacToe/themes/themeDefaut.txt | 1 + 4 files changed, 15 insertions(+), 28 deletions(-) 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 a0ac649..c45a346 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -49,11 +49,11 @@ void afficherMenu(char& choix) { fermerFichier(monFlux); // Menu - cout << endl << "MENU" << endl << "----------------------------------" << endl + cout << endl << "MENU" << endl + << "----------------------------------" << endl << "A) 1 joueur" << endl << "B) 2 joueurs" << endl - << "C) Montrer l'historique des scores" << endl - << "D) Changer le style du jeu" << endl + << "C) Changer le style du jeu" << endl << "Q) Quitter" << endl << endl << "Quel est votre choix? "; choix = toupper(_getche()); @@ -86,13 +86,6 @@ void afficherImageMenu(std::fstream& monFlux) { } //Général (plusieurs options) -void initTab(string grid[][LARGTIC]) { - for (int i = 0; i < LARGTIC; i++) { - for (int j = 0; j < LARGTIC; j++) { - grid[i][j] = " "; - } - } -} void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { SetConsoleOutputCP(CP_UTF8); @@ -106,7 +99,7 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { ouvrirFichier(monFlux, style); if (monFlux) { while (!monFlux.eof()) { - monFlux >> emoteUp >> emoteDown >> iconJ1 >> iconJ2; + monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2; } monFlux.close(); cout << endl; @@ -117,6 +110,9 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { } fermerFichier(monFlux); + grid[0][0] = ICONJ1; + grid[0][1] = ICONJ2; + // 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++) { @@ -133,27 +129,27 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { cout << endl << " "; for (int i = 0; i < LARGTIC; i++) { - cout << " |"; + cout << "|"; for (int j = 0; j < 3; j++) { cout << " "; } } - cout << " |" << endl << " " << k + 1 << " "; + cout << "|" << endl << " " << k + 1 << " "; for (int i = 0; i < LARGTIC; i++) { - cout << " |" << " " << grid[k][i] << " "; + cout << "|" << " " << grid[k][i] << " "; } cout << " |" << endl << " "; for (int i = 0; i < LARGTIC; i++) { - cout << " |"; + cout << "|"; for (int j = 0; j < 3; j++) { cout << " "; } } - cout << " |" << endl << " "; + cout << "|" << endl << " "; } @@ -346,14 +342,9 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { afficherFinMatch(grid, gagnant, nbJoueurs); } -//Historique -void historiqueDesScores() { - -} - //Changer le thème void changerLeTheme() { - string grid[LARGTIC][LARGTIC] = {ICONJ1, ICONJ2}; + string grid[LARGTIC][LARGTIC]; system("cls"); do { cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index a4da395..e1cc9cb 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -20,7 +20,6 @@ int main() { string grid[LARGTIC][LARGTIC]; do { - initTab(grid); afficherMenu(choix); switch (choix) { @@ -35,10 +34,6 @@ int main() { break; case 'C': - historiqueDesScores(); - break; - - case 'D': changerLeTheme(); break; diff --git a/TicTacToe/themes/themeDefaut.txt b/TicTacToe/themes/themeDefaut.txt index 44305f9..2c67882 100644 --- a/TicTacToe/themes/themeDefaut.txt +++ b/TicTacToe/themes/themeDefaut.txt @@ -2,3 +2,4 @@ 🔹 âœ–ï¸ â­• + \ No newline at end of file From ac31baba3da353c1e4cff664737b3fd8ed7f3315 Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 26 Nov 2025 16:12:19 -0500 Subject: [PATCH 2/2] =?UTF-8?q?Correction=20du=20choix=20du=20th=C3=A8me?= =?UTF-8?q?=20et=20du=20tableau=20=C3=A0=203=20colones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe/fonctions.cpp | 51 +++++++++++++++++++++++++++-------------- TicTacToe/fonctions.h | 3 ++- TicTacToe/main.cpp | 3 +-- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index f6d7dd7..eefaf4a 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -15,8 +15,8 @@ BUT : Fichier de fonctions Tic Tac Toe using namespace std; extern const int LARGTIC; -string ICONJ1 = "X"; -string ICONJ2 = "O"; +string iconJ1 = "X"; +string iconJ2 = "O"; string style = "themes/themeSea.txt"; int codeConsole = 0; @@ -90,15 +90,15 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { SetConsoleOutputCP(CP_UTF8); string emoteUp, emoteDown, - iconJ1, - iconJ2; + emoteJ1, + emoteJ2; // Faire une fonction pour retenir le thème sélectionné par le joueur!!!! ouvrirFichier(monFlux, style); if (monFlux) { while (!monFlux.eof()) { - monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2; + monFlux >> emoteUp >> emoteDown >> emoteJ1 >> emoteJ2; } monFlux.close(); cout << endl; @@ -109,10 +109,9 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { } fermerFichier(monFlux); - grid[0][0] = ICONJ1; - grid[0][1] = ICONJ2; - // Lignes de code pour faire afficher le Tic Tac Toe une fois que les symboles ont été ajoutés + cout << "Joueur 1: " << emoteJ1 << " Joueur 2: " << emoteJ2 << endl << endl; + cout << " "; for (int i = 0; i < LARGTIC; i++) { cout << " " << i + 1 << " "; @@ -132,21 +131,32 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { for (int j = 0; j < 3; j++) { cout << " "; } + cout << " "; } cout << "|" << endl << " " << k + 1 << " "; for (int i = 0; i < LARGTIC; i++) { - cout << "|" << " " << grid[k][i] << " "; - + cout << "|" << " " ; + if (grid[k][i] == "X") { + cout << emoteJ1; + } + else if (grid[k][i] == "O") { + cout << emoteJ2; + } + else { + cout << " "; + } + cout << " "; } - cout << " |" << endl << " "; + cout << "|" << endl << " "; for (int i = 0; i < LARGTIC; i++) { cout << "|"; for (int j = 0; j < 3; j++) { cout << " "; } + cout << " "; } cout << "|" << endl << " "; @@ -189,19 +199,23 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { verticale -= 1; horizontale -= 1; - while (grid[verticale][horizontale] == ICONJ1 || grid[verticale][horizontale] == ICONJ2) { + while (grid[verticale][horizontale] == iconJ1 || grid[verticale][horizontale] == iconJ2) { + // VÉRIFIER LE CIN D'ERREUR!!!!! cout << "\n\nVeuillez choisir une case vide.\n" << "\n\nEntrez une coordonnee verticale : "; cin >> verticale; cout << "\nEntrez une coordonnee horizontale : "; cin >> horizontale; + + verticale--; + horizontale--; } if (joueur == 1) { - grid[verticale - 1][horizontale - 1] = ICONJ1; + grid[verticale][horizontale] = iconJ1; } else { - grid[verticale - 1][horizontale - 1] = ICONJ2; + grid[verticale][horizontale] = iconJ2; } } @@ -315,8 +329,8 @@ void tourOrdi(string grid[][LARGTIC]) { do { vertical = rand() % (3); horizontal = rand() % (3); - } while (grid[vertical][horizontal] != " "); - grid[vertical][horizontal] = ICONJ2; + } while (grid[vertical][horizontal] != ""); + grid[vertical][horizontal] = iconJ2; afficherImageTableau(grid, style); } @@ -342,7 +356,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { } //Changer le thème -void changerLeTheme() { +void changerLeTheme(bool &theme) { string grid[LARGTIC][LARGTIC]; system("cls"); do { @@ -354,6 +368,9 @@ void changerLeTheme() { choix = toupper(_getche()); cout << endl; + if (choix >= 'A' && choix <= 'D') { + theme = true; + } switch (choix) { case 'A': style = "themes/themeSea.txt"; diff --git a/TicTacToe/fonctions.h b/TicTacToe/fonctions.h index 1b58e2c..5889249 100644 --- a/TicTacToe/fonctions.h +++ b/TicTacToe/fonctions.h @@ -35,4 +35,5 @@ void tourOrdi(std::string grid[][LARGTIC]); void jeuDeuxJoueurs(std::string grid[][LARGTIC]); //Changer le thème -void changerLeTheme(); \ No newline at end of file +void changerLeTheme(bool& theme); + diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index 3dc813b..b3863aa 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -45,8 +45,7 @@ int main() { break; case 'C': - changerLeTheme(); - theme = true; + changerLeTheme(theme); break; case 'Q':