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 db8dc0d..09c9118 100644 --- a/mesFonctions.cpp +++ b/mesFonctions.cpp @@ -142,11 +142,13 @@ bool effectuerTour() { string lettrePlayer; do { + cout << "Le mot est " << motRandom << endl; // TODO: RETIRER SA cout << setw(69) << "Tentative des mots de " << nbLettre << " #" << nbTentative + 1 << endl; cout << setw(69) << "Saisir votre mot : "; cin >> motPlayer; //TODO: mettre tolower string (boucle) } while (motPlayer.length() != nbLettre); + nbBonneLettre = 0; if (dansListe(motPlayer)) { cout << setw(66) << "Votre mot est : " << motPlayer << endl; @@ -167,6 +169,11 @@ bool effectuerTour() afficherMotPlayer(lettrePlayer, PAS_LA); } } + + if (nbBonneLettre == nbLettre) + { + return true; + } cout << endl; } else { @@ -175,14 +182,7 @@ bool effectuerTour() nbTentative--; } } - if (nbBonneLettre == nbLettre) - { - return true; - } - else - { - return false; - } + return false; } @@ -212,6 +212,7 @@ bool dansListe(string motPlayer) { } int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i) { + int retour = PAS_LA; for (int k = 0; k < nbLettre; k++) { @@ -219,10 +220,10 @@ int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i) { return BONNE_PLACE; } else if ((motRandom[k] == motPlayer[i]) && i != k) { - return MAUVAIS_PLACE; + retour = MAUVAIS_PLACE; } } - return PAS_LA; + return retour; } //Affichage couleur des lettres diff --git a/mesFonctions.h b/mesFonctions.h index f29b93e..b2ce0eb 100644 --- a/mesFonctions.h +++ b/mesFonctions.h @@ -33,7 +33,7 @@ string goToLine(fstream& monFlux, int numeroLigne); bool effectuerTour(); bool dansListe(string motPlayer); -bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne); +//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);