diff --git a/0 b/0 index 4588032..d7619da 100644 --- a/0 +++ b/0 @@ -1 +1 @@ -Appuyez sur une touche pour continuer... +Appuyez sur une touche pour continuer... \ No newline at end of file diff --git a/main.cpp b/main.cpp index e36fc03..2f2e916 100644 --- a/main.cpp +++ b/main.cpp @@ -42,8 +42,14 @@ int main() { curseur(true); system("cls"); - - effectuerTour(); + if (effectuerTour()) { + // Victoire + cout << "VICTOIRE !!!"; + } + else { + // Défaite + cout << "DEFAITE !!!"; + } break; case '2': diff --git a/mesFonctions.cpp b/mesFonctions.cpp index 8a0312d..db8dc0d 100644 --- a/mesFonctions.cpp +++ b/mesFonctions.cpp @@ -123,9 +123,10 @@ string goToLine(fstream& monFlux, int numeroLigne) {//g return mot; } -void effectuerTour() +bool effectuerTour() { string motRandom; + int nbBonneLettre = 0; if (nbLettre == 3) { motRandom = choisirMot("Mots/mot3lettres.txt"); } @@ -155,6 +156,7 @@ void effectuerTour() if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == BONNE_PLACE) { lettrePlayer = motPlayer[i]; afficherMotPlayer(lettrePlayer, BONNE_PLACE); + nbBonneLettre++; } else if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == MAUVAIS_PLACE) { lettrePlayer = motPlayer[i]; @@ -173,6 +175,14 @@ void effectuerTour() nbTentative--; } } + if (nbBonneLettre == nbLettre) + { + return true; + } + else + { + return false; + } } diff --git a/mesFonctions.h b/mesFonctions.h index ac20825..f29b93e 100644 --- a/mesFonctions.h +++ b/mesFonctions.h @@ -31,7 +31,7 @@ int nombreLigneFichier(fstream& monFlux); string choisirMot(string nomFichier); string goToLine(fstream& monFlux, int numeroLigne); -void effectuerTour(); +bool effectuerTour(); bool dansListe(string motPlayer); bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne); int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i);