diff --git a/mesFonctions.cpp b/mesFonctions.cpp index cab89d2..260cb5c 100644 --- a/mesFonctions.cpp +++ b/mesFonctions.cpp @@ -87,30 +87,31 @@ void curseur(bool interrupteur) { 1 - JOUER ====================================*/ //fonction pour choisir le mot de facon random -void choisirMot(string nomFichier, int maximum) { - int numeroLigne = rand() % (maximum)+1; - - fstream monFlux; - ouvrirFichier(monFlux, nomFichier); - string mot = goToLine(monFlux, numeroLigne); - fermerFichier(monFlux); -} -string goToLine(fstream& monFlux, int numeroLigne) { - string mot; - for (int i = 0; i < numeroLigne; i++) { - getline(monFlux, mot); - } - return mot; -} - -void afficherMenuJouer() { +void afficherMenuJouer() +{ cout << setw(83) << "=============================================\n"; string motPlayer; - do + + for (int i = 0; i < 6; i++) { - cout << setw(69) << "Saisir votre mot : "; - cin >> motPlayer; - } while (motPlayer.length() > 3); + do + { + cout << setw(65) << "Tentative #" << i + 1 << endl; + cout << setw(69) << "Saisir votre mot : "; + cin >> motPlayer; + } while (motPlayer.length() > 3); + + if (dansListe(motPlayer)) + { + + } + else + { + cout << setw(58) << "Mot n'est pas dans la liste"; + i--; + } + } + cout << setw(66) << "Votre mot est : " << motPlayer; diff --git a/mesFonctions.h b/mesFonctions.h index a20d0dd..af34d7d 100644 --- a/mesFonctions.h +++ b/mesFonctions.h @@ -32,4 +32,6 @@ void backgroundDefault(); void choisirMot(string nomFichier, int maximum); string goToLine(fstream& monFlux, int numeroLigne); -void afficherMenuJouer(); \ No newline at end of file +void afficherMenuJouer(); +bool dansListe(string motPlayer); +bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne); \ No newline at end of file