diff --git a/mesFonctions.cpp b/mesFonctions.cpp index fb81584..9624d02 100644 --- a/mesFonctions.cpp +++ b/mesFonctions.cpp @@ -106,6 +106,8 @@ string goToLine(fstream& monFlux, int numeroLigne) {//g void effectuerTour(int nbLettre) { + fstream monFlux; + string nomFichier; HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);//pour la couleur string motRandom = choisirMot("Mots/mot3lettres.txt", 15); @@ -129,23 +131,34 @@ void effectuerTour(int nbLettre) for (int i = 0; i < nbLettre; i++) { if (motRandom[i] == motPlayer[i]) { - - SetConsoleTextAttribute(hconsole, 2);//mettre la lettre en vert - cout << motPlayer[i]; - SetConsoleTextAttribute(hconsole, 15);//remettre le texte en blanc + string lettrePlayer; + lettrePlayer = motPlayer[i]; + lettrePlayer.insert(0, "Alphabet/Normal/"); + lettrePlayer.insert(17, ".txt"); + nomFichier = lettrePlayer; + ouvrirFichier(monFlux, nomFichier); + printLettre(monFlux, 1); + fermerFichier(monFlux); } else if (lettreDansMot(motRandom, motPlayer, nbLettre)) { - - SetConsoleTextAttribute(hconsole, 6);//mettre la lettre en vert - cout << motPlayer[i]; - SetConsoleTextAttribute(hconsole, 15);//remettre le texte en blanc - + string lettrePlayer; + lettrePlayer = motPlayer[i]; + lettrePlayer.insert(0, "Alphabet/Normal/"); + lettrePlayer.insert(17, ".txt"); + nomFichier = lettrePlayer; + ouvrirFichier(monFlux, nomFichier); + printLettre(monFlux, 2); + fermerFichier(monFlux); } else { - - SetConsoleTextAttribute(hconsole, 8);//mettre la lettre en vert - cout << motPlayer[i]; - SetConsoleTextAttribute(hconsole, 15);//remettre le texte en blanc + string lettrePlayer; + lettrePlayer = motPlayer[i]; + lettrePlayer.insert(0, "Alphabet/Normal/"); + lettrePlayer.insert(17, ".txt"); + nomFichier = lettrePlayer; + ouvrirFichier(monFlux, nomFichier); + printLettre(monFlux, 3); + fermerFichier(monFlux); } } cout << endl; @@ -258,7 +271,7 @@ void printLettre(fstream& monFlux, int positionLettre) { } else if (positionLettre == 3 /*Lettre non présente*/) { - couleurLettre = 00; + couleurLettre = 8; } else /*Pas une lettre*/ { diff --git a/mesFonctions.h b/mesFonctions.h index 65e2a7e..3c50caf 100644 --- a/mesFonctions.h +++ b/mesFonctions.h @@ -35,4 +35,5 @@ string goToLine(fstream& monFlux, int numeroLigne); void effectuerTour(int nbLettre); bool dansListe(string motPlayer); bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne); -bool lettreDansMot(string motRandom, string motPlayer, int nbLettre); \ No newline at end of file +bool lettreDansMot(string motRandom, string motPlayer, int nbLettre); +void printLettre(fstream& monFlux, int positionLettre); \ No newline at end of file