diff --git a/0 b/0 index d7619da..4588032 100644 --- a/0 +++ b/0 @@ -1 +1 @@ -Appuyez sur une touche pour continuer... \ No newline at end of file +Appuyez sur une touche pour continuer... diff --git a/mesFonctions.cpp b/mesFonctions.cpp index fb76a47..a2b5fdb 100644 --- a/mesFonctions.cpp +++ b/mesFonctions.cpp @@ -110,9 +110,6 @@ 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", NOMBREMOT3LETTRE); @@ -122,6 +119,7 @@ void effectuerTour(int nbLettre) for (int nbTentative = 0; nbTentative < nbEssai; nbTentative++) { + string lettrePlayer; do { cout << setw(65) << "Tentative #" << nbTentative + 1 << endl; cout << setw(69) << "Saisir votre mot : "; @@ -135,34 +133,16 @@ void effectuerTour(int nbLettre) for (int i = 0; i < nbLettre; i++) { if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == BONNE_PLACE) { - string lettrePlayer; lettrePlayer = motPlayer[i]; - lettrePlayer.insert(0, "Alphabet/"); - lettrePlayer.append(".txt"); - nomFichier = lettrePlayer; - ouvrirFichier(monFlux, nomFichier); - printLettre(monFlux, 1); - fermerFichier(monFlux); + afficherMotPlayer(lettrePlayer, BONNE_PLACE); } else if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == MAUVAIS_PLACE) { - string lettrePlayer; lettrePlayer = motPlayer[i]; - lettrePlayer.insert(0, "Alphabet/"); - lettrePlayer.append(".txt"); - nomFichier = lettrePlayer; - ouvrirFichier(monFlux, nomFichier); - printLettre(monFlux, 2); - fermerFichier(monFlux); + afficherMotPlayer(lettrePlayer, MAUVAIS_PLACE); } else { - string lettrePlayer; lettrePlayer = motPlayer[i]; - lettrePlayer.insert(0, "Alphabet/"); - lettrePlayer.append(".txt"); - nomFichier = lettrePlayer; - ouvrirFichier(monFlux, nomFichier); - printLettre(monFlux, 3); - fermerFichier(monFlux); + afficherMotPlayer(lettrePlayer, PAS_LA); } } cout << endl; @@ -228,7 +208,24 @@ void choixNbEssai() { /*==================================== Affichage couleur des lettres ====================================*/ -void printLettre(fstream& monFlux, int positionLettre) { +void afficherMotPlayer(string lettrePlayer, int positionLettre) +{ + fstream monFlux; + string nomFichier; + + HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);//pour la couleur + + + lettrePlayer.insert(0, "Alphabet/"); + lettrePlayer.append(".txt"); + nomFichier = lettrePlayer; + ouvrirFichier(monFlux, nomFichier); + printLettre(monFlux, positionLettre); + fermerFichier(monFlux); +} + +void printLettre(fstream& monFlux, int positionLettre) +{ int couleurLettre; if (positionLettre == 1 /*Lettre bien placé*/) { diff --git a/mesFonctions.h b/mesFonctions.h index 76e4d50..e22e175 100644 --- a/mesFonctions.h +++ b/mesFonctions.h @@ -33,6 +33,7 @@ void effectuerTour(int nbLettre); bool dansListe(string motPlayer); bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne); int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i); +void afficherMotPlayer(string lettrePlayer, int positionLettre); void printLettre(fstream& monFlux, int positionLettre); /*====================================