Changement alphabet + ajout TODO
This commit is contained in:
@@ -24,7 +24,8 @@ using namespace std::chrono_literals;
|
||||
#include <limits> //Sources : https://www.tutorialspoint.com/cpp_standard_library/limits.htm et https://stackoverflow.com/questions/2158943/split-string-into-array-of-chars
|
||||
|
||||
const int BONNE_PLACE = 1, MAUVAIS_PLACE = 2, PAS_LA = 3;
|
||||
extern const int NOMBREMOT3LETTRE = 51;
|
||||
extern const int NOMBREMOT3LETTRE = 56;
|
||||
extern int nbEssai = 6;
|
||||
|
||||
/*====================================
|
||||
MENU
|
||||
@@ -41,6 +42,7 @@ void ouvrirFichier(fstream& monFlux, string nomFichier) {
|
||||
monFlux.open(nomFichier, ios::in);
|
||||
if (!monFlux) {
|
||||
cout << "Une erreur est survenue ! Veuillez relancer le programme.";
|
||||
system("PAUSE");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -118,12 +120,12 @@ void effectuerTour(int nbLettre)
|
||||
|
||||
string motPlayer;
|
||||
|
||||
for (int nbTentative = 0; nbTentative < 6; nbTentative++)
|
||||
for (int nbTentative = 0; nbTentative < nbEssai; nbTentative++)
|
||||
{
|
||||
do {
|
||||
cout << setw(65) << "Tentative #" << nbTentative + 1 << endl;
|
||||
cout << setw(69) << "Saisir votre mot : ";
|
||||
cin >> motPlayer;
|
||||
cin >> motPlayer; //TODO: mettre tolower string (boucle)
|
||||
} while (motPlayer.length() != nbLettre);
|
||||
|
||||
if (dansListe(motPlayer)) {
|
||||
@@ -135,8 +137,8 @@ void effectuerTour(int nbLettre)
|
||||
if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == BONNE_PLACE) {
|
||||
string lettrePlayer;
|
||||
lettrePlayer = motPlayer[i];
|
||||
lettrePlayer.insert(0, "Alphabet/Normal/");
|
||||
lettrePlayer.insert(17, ".txt");
|
||||
lettrePlayer.insert(0, "Alphabet/");
|
||||
lettrePlayer.append(".txt");
|
||||
nomFichier = lettrePlayer;
|
||||
ouvrirFichier(monFlux, nomFichier);
|
||||
printLettre(monFlux, 1);
|
||||
@@ -145,8 +147,8 @@ void effectuerTour(int nbLettre)
|
||||
else if (lettreDansMot(motRandom, motPlayer, nbLettre, i) == MAUVAIS_PLACE) {
|
||||
string lettrePlayer;
|
||||
lettrePlayer = motPlayer[i];
|
||||
lettrePlayer.insert(0, "Alphabet/Normal/");
|
||||
lettrePlayer.insert(17, ".txt");
|
||||
lettrePlayer.insert(0, "Alphabet/");
|
||||
lettrePlayer.append(".txt");
|
||||
nomFichier = lettrePlayer;
|
||||
ouvrirFichier(monFlux, nomFichier);
|
||||
printLettre(monFlux, 2);
|
||||
@@ -155,8 +157,8 @@ void effectuerTour(int nbLettre)
|
||||
else {
|
||||
string lettrePlayer;
|
||||
lettrePlayer = motPlayer[i];
|
||||
lettrePlayer.insert(0, "Alphabet/Normal/");
|
||||
lettrePlayer.insert(17, ".txt");
|
||||
lettrePlayer.insert(0, "Alphabet/");
|
||||
lettrePlayer.append(".txt");
|
||||
nomFichier = lettrePlayer;
|
||||
ouvrirFichier(monFlux, nomFichier);
|
||||
printLettre(monFlux, 3);
|
||||
@@ -167,7 +169,7 @@ void effectuerTour(int nbLettre)
|
||||
}
|
||||
else {
|
||||
cout << setw(66) << "Votre mot est : " << motPlayer;
|
||||
cout << endl << setw(75) << "Mot n'est pas dans la liste\n\n";
|
||||
cout << endl << setw(75) << "Mot n'est pas dans la liste\n\n"; //TODO: Ajouter dans essai.txt
|
||||
nbTentative--;
|
||||
}
|
||||
}
|
||||
@@ -214,48 +216,11 @@ int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i) {
|
||||
/*====================================
|
||||
2 - OPTIONS
|
||||
====================================*/
|
||||
void background(int couleur) {
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
switch (couleur) {
|
||||
case '1':
|
||||
SetConsoleTextAttribute(hConsole, BACKGROUND_RED | BACKGROUND_INTENSITY);
|
||||
break;
|
||||
|
||||
case '2':
|
||||
SetConsoleTextAttribute(hConsole, BACKGROUND_RED);
|
||||
break;
|
||||
|
||||
case '3':
|
||||
SetConsoleTextAttribute(hConsole, BACKGROUND_BLUE);
|
||||
break;
|
||||
|
||||
case '4':
|
||||
SetConsoleTextAttribute(hConsole, BACKGROUND_GREEN);
|
||||
break;
|
||||
|
||||
case '5':
|
||||
//SetConsoleTextAttribute(hConsole, BACKGROUND_RED | BACKGROUND_INTENSITY);
|
||||
break;
|
||||
|
||||
case '6':
|
||||
//SetConsoleTextAttribute(hConsole, BACKGROUND_RED | BACKGROUND_INTENSITY);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetConsoleTextAttribute(hConsole, BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
|
||||
}
|
||||
}
|
||||
|
||||
int demanderBackground() {
|
||||
cout << "Choix";
|
||||
int choix = _getche();
|
||||
return choix;
|
||||
}
|
||||
|
||||
void backgroundDefault() {
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
SetConsoleTextAttribute(hConsole, 0x0F);
|
||||
void choixNbEssai() {
|
||||
cout << "Veuillez choisir le nombre de tentative que vous souhaitez avoir :"
|
||||
<< "\n(Par defaut a 6)"
|
||||
<< endl;
|
||||
cin >> nbEssai;
|
||||
}
|
||||
|
||||
/*====================================
|
||||
|
||||
Reference in New Issue
Block a user