diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index 883abcd..75b92e7 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -49,7 +49,7 @@ void afficherMenu(char& choix) { fermerFichier(monFlux); // Menu - cout << endl << "MENU" << endl + cout << endl << "MENU" << endl << "----------------------------------" << endl << "A) 1 joueur" << endl << "B) 2 joueurs" << endl @@ -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; @@ -110,6 +110,8 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) { fermerFichier(monFlux); // 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 << " "; @@ -125,27 +127,38 @@ 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 << " "; } - cout << " |" << endl << " " << k + 1 << " "; + 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 << " |"; + cout << "|"; for (int j = 0; j < 3; j++) { cout << " "; } + cout << " "; } - cout << " |" << endl << " "; + cout << "|" << endl << " "; } @@ -187,18 +200,22 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { 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 - 1][horizontale - 1] = ICONJ1; + grid[verticale][horizontale] = ICONJ1; } else { - grid[verticale - 1][horizontale - 1] = ICONJ2; + grid[verticale][horizontale] = ICONJ2; } } @@ -312,7 +329,7 @@ void tourOrdi(string grid[][LARGTIC]) { do { vertical = rand() % (3); horizontal = rand() % (3); - } while (grid[vertical][horizontal] != " "); + } while (grid[vertical][horizontal] != ""); grid[vertical][horizontal] = ICONJ2; afficherImageTableau(grid, style); } @@ -339,8 +356,8 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { } //Changer le thème -void changerLeTheme() { - string grid[LARGTIC][LARGTIC] = {ICONJ1, ICONJ2}; +void changerLeTheme(bool &theme) { + string grid[LARGTIC][LARGTIC]; system("cls"); do { cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl @@ -351,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/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