UPDATE MAJEUR : Intégration des mots de 4 lettres.

This commit is contained in:
2025-12-05 19:10:00 -05:00
parent 673920523a
commit 7b6611065c
7 changed files with 145 additions and 19 deletions

View File

@@ -25,7 +25,9 @@ using namespace std::chrono_literals;
const int BONNE_PLACE = 1, MAUVAIS_PLACE = 2, PAS_LA = 3;
extern const int NOMBREMOT3LETTRE = 101;
extern const int NOMBREMOT4LETTRE = 74;
extern int nbEssai = 6;
extern int nbLettre = 4;
/*====================================
MENU
@@ -110,8 +112,13 @@ string goToLine(fstream& monFlux, int numeroLigne) {//g
void effectuerTour(int nbLettre)
{
string motRandom = choisirMot("Mots/mot3lettres.txt", NOMBREMOT3LETTRE);
string motRandom;
if (nbLettre == 3) {
motRandom = choisirMot("Mots/mot3lettres.txt", NOMBREMOT3LETTRE);
}
else if (nbLettre == 4) {
motRandom = choisirMot("Mots/mot4lettres.txt", NOMBREMOT4LETTRE);
}
cout << setw(83) << "=============================================\n";
@@ -157,18 +164,30 @@ void effectuerTour(int nbLettre)
bool dansListe(string motPlayer) {
fstream monFlux;
ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
string mot;
for (int i = 0; i < NOMBREMOT3LETTRE; i++) {
getline(monFlux, mot);
if (nbLettre == 3) {
ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
for (int i = 0; i < NOMBREMOT3LETTRE; i++) {
getline(monFlux, mot);
if (motPlayer == mot)
{
fermerFichier(monFlux);
return true;
if (motPlayer == mot)
{
fermerFichier(monFlux);
return true;
}
}
}
else if (nbLettre == 4) {
ouvrirFichier(monFlux, "Mots/mot4lettres.txt");
for (int i = 0; i < NOMBREMOT4LETTRE; i++) {
getline(monFlux, mot);
if (motPlayer == mot)
{
fermerFichier(monFlux);
return true;
}
}
}
fermerFichier(monFlux);
@@ -254,11 +273,34 @@ void printLettre(fstream& monFlux, int positionLettre)
/*====================================
2 - OPTIONS
====================================*/
void choixNbEssai() {
void choixNbEssai()
{
cout << "Veuillez choisir le nombre de tentative que vous souhaitez avoir."
<< "\nPar defaut, le nombre de tentative est a 6."
<< endl
<< "Nombre de tentative : ";
cin >> nbEssai;
cout << "Vous avez choisi d'avoir " << nbEssai << " tentatives.";
cout << "Vous avez choisi d'avoir " << nbEssai << " tentatives."
<< endl
<< endl;
}
void choixLongeurMot() {
cout << "Veuillez choisir la longueur des mots a deviner."
<< "\nPar defaut, la longeur est a 3 lettres."
<< "\n***Pour le moment, uniquement les mots de 3 et de 4 lettres fonctionnent.***"
<< endl
<< "Longeur des mots : ";
cin >> nbLettre;
if (nbLettre == 3 || nbLettre == 4) {
cout << "Vous avez choisi d'avoir " << nbLettre << " lettres dans les mots a trouver."
<< endl
<< endl;
}
else {
nbLettre = 3;
cout << "Choix non disponible, nous avons choisis pour vous. Les mots auront 3 lettres."
<< endl
<< endl;
}
}