From 3ac1c10f8a3f7e5fbe38552f51a2a588c062280c Mon Sep 17 00:00:00 2001 From: Lea Date: Fri, 28 Nov 2025 09:42:12 -0500 Subject: [PATCH 1/2] =?UTF-8?q?cr=C3=A9ation=20d'une=20branche=20secondair?= =?UTF-8?q?e=20(je=20pense=20que=20=C3=A7'a=20march=C3=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TicTacToe/fonctions.cpp | 1 + TicTacToe/main.cpp | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index fe0ab2b..879baa0 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -339,6 +339,7 @@ void tourOrdi(string grid[][LARGTIC]) { vertical = rand() % (3); horizontal = rand() % (3); } while (grid[vertical][horizontal] != ""); + grid[vertical][horizontal] = iconJ2; afficherImageTableau(grid, style); } diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index f167b50..6e7d9e3 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -23,28 +23,17 @@ int main() { switch (choix) { case 'A': - if (theme == true) { - system("cls"); - jeuUnJoueur(grid); - } - else { - cout << "\n\nVeuillez choisir un theme d'abord."; - } + system("cls"); + jeuUnJoueur(grid); break; case 'B': - if (theme == true) { - system("cls"); - jeuDeuxJoueurs(grid); - } - else { - cout << "\n\nVeuillez choisir un theme d'abord."; - } + system("cls"); + jeuDeuxJoueurs(grid); break; case 'C': changerLeTheme(theme); - theme = true; break; case 'Q': From d8889c6f4fa7ced0fb7c0e246623a381ca6fc21f Mon Sep 17 00:00:00 2001 From: Lea Date: Fri, 28 Nov 2025 09:58:25 -0500 Subject: [PATCH 2/2] modifications sur plusieurs niveaux --- TicTacToe/fonctions.cpp | 105 ++++++++++++++++++++-------------------- TicTacToe/fonctions.h | 2 +- TicTacToe/main.cpp | 3 +- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index 879baa0..bd9a1f5 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -95,7 +95,7 @@ void initGrid(string grid[][LARGTIC]) { } void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { - SetConsoleOutputCP(CP_UTF8); + SetConsoleOutputCP(CP_UTF8); //affiche les émojis string emoteUp, emoteDown, emoteJ1, @@ -180,53 +180,6 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { SetConsoleOutputCP(codeConsole); } -void tourJoueur(string grid[][LARGTIC], int joueur) { - int verticale, - horizontale; - - cout << "\n\nTour du joueur " << joueur << endl; - afficherImageTableau(grid, style); - - cout << "\n\nEntrez une coordonnee verticale : "; - cin >> verticale; - - while (verticale < 1 || verticale > 3) { - cout << "\n\nVeuillez entrer une donnee valide.\n" - << "\n\nEntrez une coordonnee verticale : "; - cin >> verticale; - } - - cout << "\nEntrez une coordonnee horizontale : "; - cin >> horizontale; - - while (horizontale < 1 || horizontale > 3) { - cout << "\n\nVeuillez entrer une donnee valide.\n" - << "\n\nEntrez une coordonnee horizontale : "; - cin >> horizontale; - } - - verticale -= 1; - horizontale -= 1; - - 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][horizontale] = iconJ1; - } - else { - grid[verticale][horizontale] = iconJ2; - } -} bool verifFinMatch(std::string grid[][LARGTIC]) { bool fin = false; @@ -308,6 +261,55 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { } } +// Joueur +void tourJoueur(string grid[][LARGTIC], int joueur) { + int verticale, + horizontale; + + cout << "\n\nTour du joueur " << joueur << endl; + afficherImageTableau(grid, style); + + cout << "\n\nEntrez une coordonnee verticale : "; + cin >> verticale; + + while (verticale < 1 || verticale > 3) { + cout << "\n\nVeuillez entrer une donnee valide.\n" + << "\n\nEntrez une coordonnee verticale : "; + cin >> verticale; + } + + cout << "\nEntrez une coordonnee horizontale : "; + cin >> horizontale; + + while (horizontale < 1 || horizontale > 3) { + cout << "\n\nVeuillez entrer une donnee valide.\n" + << "\n\nEntrez une coordonnee horizontale : "; + cin >> horizontale; + } + + verticale -= 1; + horizontale -= 1; + + 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][horizontale] = iconJ1; + } + else { + grid[verticale][horizontale] = iconJ2; + } +} + //1 joueur void jeuUnJoueur(string grid[][LARGTIC]) { bool fin; @@ -366,7 +368,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { } //Changer le thème -void changerLeTheme(bool& theme) { +void changerLeTheme() { string grid[LARGTIC][LARGTIC]; system("cls"); cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl; @@ -380,9 +382,6 @@ void changerLeTheme(bool& theme) { choix = toupper(_getche()); cout << endl; - if (choix >= 'A' && choix <= 'D') { - theme = true; - } switch (choix) { case 'A': style = "themes/themeDefaut.txt"; @@ -484,4 +483,4 @@ void changerLeTheme(bool& theme) { break; } } while (choix != 'Q'); -} \ No newline at end of file +} diff --git a/TicTacToe/fonctions.h b/TicTacToe/fonctions.h index 4ffdd05..b89ad28 100644 --- a/TicTacToe/fonctions.h +++ b/TicTacToe/fonctions.h @@ -35,4 +35,4 @@ void tourOrdi(std::string grid[][LARGTIC]); void jeuDeuxJoueurs(std::string grid[][LARGTIC]); //Changer le thème -void changerLeTheme(bool& theme); \ No newline at end of file +void changerLeTheme(); \ No newline at end of file diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index 6e7d9e3..7afcc1d 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -13,7 +13,6 @@ using namespace std; int main() { srand(time(NULL)); - bool theme = false; char choix; string grid[LARGTIC][LARGTIC]; @@ -33,7 +32,7 @@ int main() { break; case 'C': - changerLeTheme(theme); + changerLeTheme(); break; case 'Q':