Compare commits

..

2 Commits

Author SHA1 Message Date
William
f754bebf05 Merge branch 'main' of https://gitea.zkd.ca/TAXON/taxon 2025-11-28 09:36:51 -05:00
William
4e2b25c906 rework de tout le code 2025-11-28 09:36:43 -05:00
3 changed files with 44 additions and 46 deletions

View File

@@ -25,6 +25,7 @@ int main() {
bool quitter = false; //Quitter le jeu bool quitter = false; //Quitter le jeu
int nbMot3lettre = 15; //Nombre de mot pr<70>sent dans le fichier int nbMot3lettre = 15; //Nombre de mot pr<70>sent dans le fichier
int temp = 0; //TODO: Variable temporaire int temp = 0; //TODO: Variable temporaire
string motRandom; // Mot random
while (quitter == false) { while (quitter == false) {
curseur(false); curseur(false);
@@ -34,33 +35,33 @@ int main() {
int choixMenu = _getch(); int choixMenu = _getch();
switch (choixMenu) { switch (choixMenu) {
case '1': case '1':
afficherMenu("AfficheMenu/TaxonOption1.txt"); afficherMenu("AfficheMenu/TaxonOption1.txt");
delai(); delai();
curseur(true); curseur(true);
system("cls"); system("cls");
background(temp); background(temp);
choisirMot("Mots/mot3lettres.txt", nbMot3lettre); motRandom = choisirMot("Mots/mot3lettres.txt", nbMot3lettre);
afficherMenuJouer(); afficherMenuJouer();
break; break;
case '2': case '2':
afficherMenu("AfficheMenu/TaxonOption2.txt"); afficherMenu("AfficheMenu/TaxonOption2.txt");
delai(); delai();
curseur(true); curseur(true);
system("cls"); system("cls");
temp = demanderBackground(); temp = demanderBackground();
background(temp); background(temp);
break; break;
case '3': case '3':
afficherMenu("AfficheMenu/TaxonOption3.txt"); afficherMenu("AfficheMenu/TaxonOption3.txt");
delai(); delai();
background('1'); background('1');
afficherMenu("AfficheMenu/Quitter.txt"); afficherMenu("AfficheMenu/Quitter.txt");
quitter = true; quitter = true;
break; break;
} }
system("PAUSE>0"); system("PAUSE>0");
system("cls"); system("cls");

View File

@@ -87,18 +87,15 @@ void curseur(bool interrupteur) {
1 - JOUER 1 - JOUER
====================================*/ ====================================*/
//fonction pour choisir le mot de facon random //fonction pour choisir le mot de facon random
void choisirMot(string nomFichier, int maximum) { string choisirMot(string nomFichier, int maximum) {//Choisi un mot al<61>atoire et le renvoi
system("cls");
int numeroLigne = rand() % (maximum)+1; int numeroLigne = rand() % (maximum)+1;
fstream monFlux; fstream monFlux;
ouvrirFichier(monFlux, nomFichier); ouvrirFichier(monFlux, nomFichier);
string mot = goToLine(monFlux, numeroLigne); string motRandom = goToLine(monFlux, numeroLigne);
fermerFichier(monFlux); fermerFichier(monFlux);
return motRandom;
} }
string goToLine(fstream& monFlux, int numeroLigne) { string goToLine(fstream& monFlux, int numeroLigne) {//g<>n<EFBFBD>re un nb al<61>atoire, et choisi une ligne associ<63> pour un mot al<61>atoire. renvoi le mot choisi
string mot; string mot;
for (int i = 0; i < numeroLigne; i++) { for (int i = 0; i < numeroLigne; i++) {
getline(monFlux, mot); getline(monFlux, mot);
@@ -109,25 +106,25 @@ string goToLine(fstream& monFlux, int numeroLigne) {
void afficherMenuJouer() void afficherMenuJouer()
{ {
cout << setw(83) << "=============================================\n"; cout << setw(83) << "=============================================\n";
string motPlayer;
for (int i = 0; i < 6; i++) string motPlayer;
for (int nbTentative = 0; nbTentative < 6; nbTentative++)
{ {
do do
{ {
cout << setw(65) << "Tentative #" << i + 1 << endl; cout << setw(65) << "Tentative #" << nbTentative + 1 << endl;
cout << setw(69) << "Saisir votre mot : "; cout << setw(69) << "Saisir votre mot : ";
cin >> motPlayer; cin >> motPlayer;
} while (motPlayer.length() > 3); } while (motPlayer.length() > 3);
if (dansListe(motPlayer)) if (dansListe(motPlayer))
{ {
cout << "\na continue\n";
} }
else else
{ {
cout << setw(58) << "Mot n'est pas dans la liste"; cout << setw(58) << "\nMot n'est pas dans la liste\n";
i--; nbTentative--;
} }
} }
@@ -136,27 +133,27 @@ void afficherMenuJouer()
cout << setw(66) << "Votre mot est : " << motPlayer; cout << setw(66) << "Votre mot est : " << motPlayer;
} }
bool dansListe(string motPlayer) bool dansListe(string motPlayer)
{ {
fstream monFlux; fstream monFlux;
ouvrirFichier(monFlux, "Mots/mot3lettres.txt"); ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
comparerMot(monFlux, motPlayer, 15);
}
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne)
{
string mot; string mot;
for (int i = 0; i < numeroLigne; i++) { for (int i = 0; i < 15; i++) { //TODO changer le chiffre 15 par le num<75>ro de ligne dans le ficher
getline(monFlux, mot); getline(monFlux, mot);
if (motPlayer == mot) if (motPlayer == mot)
{ {
return true; return true;
} }
} }
return false; return false;
fermerFichier(monFlux);
} }
/*==================================== /*====================================
2 - OPTIONS 2 - OPTIONS
====================================*/ ====================================*/

View File

@@ -29,7 +29,7 @@ int demanderBackground();
void backgroundDefault(); void backgroundDefault();
// Mot // Mot
void choisirMot(string nomFichier, int maximum); string choisirMot(string nomFichier, int maximum);
string goToLine(fstream& monFlux, int numeroLigne); string goToLine(fstream& monFlux, int numeroLigne);
void afficherMenuJouer(); void afficherMenuJouer();