diff --git a/TicTacToe/0 b/TicTacToe/0 index 4588032..6fe9972 100644 --- a/TicTacToe/0 +++ b/TicTacToe/0 @@ -1 +1 @@ -Appuyez sur une touche pour continuer... +Press any key to continue . . . diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index 0a69c2b..1f3f2db 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" }; +const string DEFAULT = { " " }; int codeConsole = 0; fstream monFlux; @@ -85,6 +86,11 @@ void afficherImageMenu(std::fstream& monFlux) { } //Général (plusieurs options) +void initTab(string grid[][LARGTIC]) { + grid[LARGTIC][LARGTIC]; + +} + void afficherImageTableau(std::string grid[][LARGTIC]) { SetConsoleOutputCP(CP_UTF8); string emoteUp, @@ -215,18 +221,39 @@ bool verifFinMatch(std::string grid[][LARGTIC]) { } } +void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) { + if (nbJoueurs == 1) { + if (gagnant == 1) { + cout << "\n\nLe joueur a gagne la partie!"; + } + else { + cout << "\n\nL'ordinateur a gagne la partie!"; + } + } + else { + cout << "\n\nLe joueur " << gagnant + << " a gagne la partie!"; + } +} + //1 joueur void jeuUnJoueur(string grid[][LARGTIC]) { bool fin; + int gagnant; + int nbJoueurs = 1; + cout << "\nUn joueur a ete choisi. Le joueur joue en premier.\n\n"; do { tourJoueur(grid, 1); - //fin = verifFinMatch(grid); + gagnant = 1; + fin = verifFinMatch(grid); tourOrdi(grid); + gagnant = 2; system("PAUSE>0"); fin = verifFinMatch(grid); } while (fin != true); + afficherFinMatch(grid, gagnant, nbJoueurs); } void tourOrdi(string grid[][LARGTIC]) { @@ -245,12 +272,29 @@ void tourOrdi(string grid[][LARGTIC]) { //2 joueurs void jeuDeuxJoueurs(string grid[][LARGTIC]) { bool fin; + int gagnant; + int nbJoueurs = 2; + cout << endl << "Deux joueurs a ete choisi. Les tours seront l'un a la suite de l'autre." << endl << endl; do { tourJoueur(grid, 1); + gagnant = 1; + fin = verifFinMatch(grid); tourJoueur(grid, 2); + gagnant = 2; fin = verifFinMatch(grid); // la condition doit être une série de 3 symboles pareil } while (fin != true); + afficherFinMatch(grid, gagnant, nbJoueurs); +} + +//Historique +void historiqueDesScores() { + +} + +//Changer le thème +void changerLeTheme() { + } \ No newline at end of file diff --git a/TicTacToe/fonctions.h b/TicTacToe/fonctions.h index 1f03117..ab4cfc3 100644 --- a/TicTacToe/fonctions.h +++ b/TicTacToe/fonctions.h @@ -21,13 +21,21 @@ void afficherMenu(char& choix); void afficherImageMenu(std::fstream& monFlux); //Général +void initTab(std::string grid[][LARGTIC]); void afficherImageTableau(std::string grid[][LARGTIC]); void tourJoueur(std::string grid[][LARGTIC], int joueur); //pour savoir quel icon utiliser bool verifFinMatch(std::string grid[][LARGTIC]); +void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs); //1 joueur void jeuUnJoueur(std::string grid[][LARGTIC]); void tourOrdi(std::string grid[][LARGTIC]); //2 joueurs -void jeuDeuxJoueurs(std::string grid[][LARGTIC]); \ No newline at end of file +void jeuDeuxJoueurs(std::string grid[][LARGTIC]); + +//Historique +void historiqueDesScores(); + +//Changer le thème +void changerLeTheme(); \ No newline at end of file diff --git a/TicTacToe/main.cpp b/TicTacToe/main.cpp index bf77ba4..c444faf 100644 --- a/TicTacToe/main.cpp +++ b/TicTacToe/main.cpp @@ -17,9 +17,10 @@ int main() { srand(time(NULL)); char choix; - string grid[LARGTIC][LARGTIC] = { " ", " ", " "," ", " ", " ", " ", " ", " "}; + string grid[LARGTIC][LARGTIC] = { " ", " ", " "," ", " ", " ", " ", " ", " " }; do { + initTab(grid); afficherMenu(choix); switch (choix) { @@ -34,11 +35,11 @@ int main() { break; case 'C': - + historiqueDesScores(); break; case 'D': - + changerLeTheme(); break; case 'Q':