Compare commits

...

28 Commits

Author SHA1 Message Date
95f56b5509 JEU FONCTIONNEL !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 2025-12-06 00:53:36 -05:00
f6d1303095 Ajout: Bloc de commentaire sur les test. Selon énoncé : "À la fin du développement, vous devez créer un bloc de commentaires au-dessus de la déclaration du main() pour expliquer et
indiquer les tests qui ont été effectués afin de vérifier que votre application fonctionne correctement."
2025-12-06 00:26:07 -05:00
64154b3a56 Ajout victoire et défaite 2025-12-06 00:22:49 -05:00
fa623541ff Enregistrement de mes dernieres modifications 2025-12-06 00:03:04 -05:00
24cd682bdb Implémentation total de la prise en charge en simultané des mots a 3 et 4 lettres. 2025-12-05 23:52:58 -05:00
7b6611065c UPDATE MAJEUR : Intégration des mots de 4 lettres. 2025-12-05 19:10:00 -05:00
673920523a Réorganisation du fichier mesFonctions.cpp 2025-12-05 18:08:46 -05:00
707d07fbbd Ajout docu sur les erreurs 2025-12-05 18:04:23 -05:00
eb24e9279d Simplification du système de couleur des lettres (tous est dans une fonction) 2025-12-05 17:57:26 -05:00
9dede478c0 Correctif : Menu d'option sélection du nombre de tentative. 2025-12-05 17:42:32 -05:00
dfb40af3dc Ajout à la liste des mots 2025-12-05 17:35:05 -05:00
1068695609 Changement alphabet + ajout TODO 2025-12-05 12:52:04 -05:00
150e533402 Update: liste de mots 2025-12-05 11:35:42 -05:00
02d1062f97 Ajouts de mots dans la liste 2025-12-05 11:08:26 -05:00
William
1c14c5ddb0 Merge branch 'main' of https://gitea.zkd.ca/TAXON/taxon 2025-12-05 10:22:49 -05:00
William
6027a79491 corirger lettre 2025-12-05 10:22:43 -05:00
ac8fa1e0fb Correctifs au lettres 2025-12-05 10:15:12 -05:00
William
15616971d8 changement de merde 2025-12-05 09:52:53 -05:00
b3ca976b13 Lettre graphique 2025-12-05 09:52:06 -05:00
b38c59c22d Merge branch 'main' of https://gitea.zkd.ca/TAXON/Taxon 2025-12-05 09:28:44 -05:00
438579f393 Ajout affichage graphique 2025-12-05 09:28:35 -05:00
William
72f9184b20 vérification des lettres 2025-12-05 09:27:56 -05:00
9f3028e324 Leger correctif d'un oublie 2025-11-28 10:17:30 -05:00
c7f785967e Merge branch 'main' of https://gitea.zkd.ca/TAXON/Taxon 2025-11-28 10:16:48 -05:00
b53ff47364 Alphabet en alpha testing :3 2025-11-28 10:16:42 -05:00
William
64b8ee7401 commentaire important 2025-11-28 09:50:29 -05:00
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
34 changed files with 736 additions and 140 deletions

View File

@@ -1,5 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 15 15 15 00 99
00 15 00 00 15 00 99
00 00 00 00 00 00 99

7
Alphabet/B.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 15 15 00 00 99
00 15 00 00 15 00 99
00 15 15 15 00 00 99
00 15 00 00 15 00 99
00 15 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/C.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 00 00 99
00 15 00 00 15 00 99
00 15 00 00 00 00 99
00 15 00 00 15 00 99
00 00 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/D.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 15 15 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/E.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 15 00 99
00 15 00 00 00 00 99
00 15 15 15 00 00 99
00 15 00 00 00 00 99
00 00 15 15 15 00 99
00 00 00 00 00 00 99

7
Alphabet/F.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 15 00 99
00 15 00 00 00 00 99
00 15 15 15 00 00 99
00 15 00 00 00 00 99
00 15 00 00 00 00 99
00 00 00 00 00 00 99

7
Alphabet/G.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 15 00 99
00 15 00 00 00 00 99
00 15 00 15 15 00 99
00 15 00 00 15 00 99
00 00 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/H.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 15 15 15 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 00 00 00 00 00 99

7
Alphabet/I.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 15 15 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 15 15 15 00 99
00 00 00 00 00 99

7
Alphabet/J.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 15 15 00 99
00 00 00 15 00 99
00 00 00 15 00 99
00 15 00 15 00 99
00 00 15 15 00 99
00 00 00 00 00 99

7
Alphabet/K.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 00 00 15 00 99
00 15 00 15 00 00 99
00 15 15 00 00 00 99
00 15 00 15 00 00 99
00 15 00 00 15 00 99
00 00 00 00 00 00 99

7
Alphabet/L.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 00 00 00 99
00 15 00 00 00 99
00 15 00 00 00 99
00 15 00 00 00 99
00 15 15 15 00 99
00 00 00 00 00 99

7
Alphabet/M.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 00 99
00 00 15 00 15 00 00 99
00 15 00 15 00 15 00 99
00 15 00 15 00 15 00 99
00 15 00 00 00 15 00 99
00 15 00 00 00 15 00 99
00 00 00 00 00 00 00 99

7
Alphabet/N.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 15 00 15 00 99
00 15 00 15 15 00 99
00 15 00 00 15 00 99
00 00 00 00 00 00 99

7
Alphabet/O.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 00 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/P.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 00 00 99
00 15 00 00 15 00 99
00 15 15 15 00 00 99
00 15 00 00 00 00 99
00 15 00 00 00 00 99
00 00 00 00 00 00 99

7
Alphabet/Q.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 00 99
00 00 15 15 00 00 00 99
00 15 00 00 15 00 00 99
00 15 00 00 15 00 00 99
00 15 00 00 15 00 00 99
00 00 15 15 00 15 00 99
00 00 00 00 00 00 00 99

7
Alphabet/R.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 00 00 99
00 15 00 00 15 00 99
00 15 15 15 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 00 00 00 00 00 99

7
Alphabet/S.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 00 15 15 15 00 99
00 15 00 00 00 00 99
00 00 15 15 00 00 99
00 00 00 00 15 00 99
00 15 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/T.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 15 15 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 00 00 00 00 99

7
Alphabet/U.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 15 00 00 15 00 99
00 00 15 15 00 00 99
00 00 00 00 00 00 99

7
Alphabet/V.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 00 99
00 15 00 00 00 15 00 99
00 15 00 00 00 15 00 99
00 15 00 00 00 15 00 99
00 00 15 00 15 00 00 99
00 00 00 15 00 00 00 99
00 00 00 00 00 00 00 99

7
Alphabet/W.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 00 99
00 15 00 00 00 15 00 99
00 15 00 15 00 15 00 99
00 15 00 15 00 15 00 99
00 15 00 15 00 15 00 99
00 00 15 15 15 00 00 99
00 00 00 00 00 00 00 99

7
Alphabet/X.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 00 15 00 99
00 15 00 15 00 99
00 00 15 00 00 99
00 15 00 15 00 99
00 15 00 15 00 99
00 00 00 00 00 99

7
Alphabet/Y.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 99
00 15 00 15 00 99
00 15 00 15 00 99
00 15 15 15 00 99
00 00 15 00 00 99
00 00 15 00 00 99
00 00 00 00 00 99

7
Alphabet/Z.txt Normal file
View File

@@ -0,0 +1,7 @@
00 00 00 00 00 00 99
00 15 15 15 15 00 99
00 00 00 00 15 00 99
00 00 00 15 00 00 99
00 00 15 00 00 00 99
00 15 15 15 15 00 99
00 00 00 00 00 00 99

View File

@@ -13,3 +13,89 @@ toi
moi
eux
mat
les
met
mer
dos
bon
oui
non
son
bas
mal
lot
des
sac
est
jeu
bus
eau
col
lit
lui
aie
ail
mou
dur
sel
elf
ble
gel
vue
nul
ion
fin
vie
tri
ris
lis
feu
peu
fou
pas
bac
air
ami
arc
but
car
cas
mai
mon
pin
pro
que
qui
six
sud
vif
vin
vis
vol
vos
dix
ane
art
aux
don
fan
gai
lac
rat
lys
bal
bel
dil
lin
jus
nid
bru
fer
cru
pur
tir
zoo
bat
toc
rap
tas

74
Mots/mot4lettres.txt Normal file
View File

@@ -0,0 +1,74 @@
abdo
abri
adon
afin
agir
aide
aigu
aile
aire
aise
allo
alma
alpe
alte
alto
amer
anal
ange
anti
anus
aria
arme
aube
auge
aura
auto
aval
avec
axer
azur
bave
bide
bien
bise
bite
bleu
blog
bobo
boom
boss
bouc
boue
boxe
bras
bref
bric
brin
brou
brun
buse
caca
cage
camp
case
cave
ceci
cent
cerf
chat
chef
cher
chez
chic
ciel
clou
club
cote
coup
cour
cout
crac
cran
cric
cube

View File

@@ -1,11 +1,13 @@
# Taxon
# Add to VS 2022
## Codes d'erreur
Install GIT for Windows : https://git-scm.com/install/windows
Erreur 1
```
Cette erreur peut survenir lorsqu'un fichier n'arrive pas <20> s'ouvrir ou se fermer.
```
Erreur 2
```
git config credential.helper wincred
git config user.email 'empty@zkd.ca'
git config user.name 'Nom du coequipier'
Cette erreur peut survenir lors d'un probl<62>me dans l'affichage des lettres.
```

View File

@@ -135,7 +135,34 @@
<Text Include="AfficheMenu\TaxonOption1.txt" />
<Text Include="AfficheMenu\TaxonOption2.txt" />
<Text Include="AfficheMenu\TaxonOption3.txt" />
<Text Include="Alphabet\Normal\A.txt" />
<Text Include="Alphabet\A.txt" />
<Text Include="Alphabet\B.txt" />
<Text Include="Alphabet\C.txt" />
<Text Include="Alphabet\D.txt" />
<Text Include="Alphabet\E.txt" />
<Text Include="Alphabet\F.txt" />
<Text Include="Alphabet\G.txt" />
<Text Include="Alphabet\H.txt" />
<Text Include="Alphabet\I.txt" />
<Text Include="Alphabet\J.txt" />
<Text Include="Alphabet\K.txt" />
<Text Include="Alphabet\L.txt" />
<Text Include="Alphabet\M.txt" />
<Text Include="Alphabet\N.txt" />
<Text Include="Alphabet\O.txt" />
<Text Include="Alphabet\P.txt" />
<Text Include="Alphabet\Q.txt" />
<Text Include="Alphabet\R.txt" />
<Text Include="Alphabet\S.txt" />
<Text Include="Alphabet\T.txt" />
<Text Include="Alphabet\U.txt" />
<Text Include="Alphabet\V.txt" />
<Text Include="Alphabet\W.txt" />
<Text Include="Alphabet\X.txt" />
<Text Include="Alphabet\Y.txt" />
<Text Include="Alphabet\Z.txt" />
<Text Include="Mots\mot3lettres.txt" />
<Text Include="Mots\mot4lettres.txt" />
<Text Include="TaxonLogo.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -19,17 +19,8 @@
<Filter Include="Fichiers de ressources\Alphabet">
<UniqueIdentifier>{df2ed3d4-f003-4ddf-afbb-9da73c17e1f3}</UniqueIdentifier>
</Filter>
<Filter Include="Fichiers de ressources\Alphabet\Normal">
<UniqueIdentifier>{8064397c-076b-4f78-81d1-972b604b522d}</UniqueIdentifier>
</Filter>
<Filter Include="Fichiers de ressources\Alphabet\BonEmplacement">
<UniqueIdentifier>{833d80c9-3c2f-493f-a670-3578c6c38820}</UniqueIdentifier>
</Filter>
<Filter Include="Fichiers de ressources\Alphabet\MauvaisEmplacement">
<UniqueIdentifier>{219b9b47-768d-4ad2-bc5e-06f9906b7902}</UniqueIdentifier>
</Filter>
<Filter Include="Fichiers de ressources\Alphabet\Inexistant">
<UniqueIdentifier>{0e8fa072-7227-45e7-9f12-72b6afa5933f}</UniqueIdentifier>
<Filter Include="Fichiers de ressources\Mots">
<UniqueIdentifier>{e4854bf8-7fba-4be2-912e-80d765ca577e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
@@ -58,15 +49,96 @@
<Text Include="AfficheMenu\TaxonOption3.txt">
<Filter>Fichiers de ressources\AfficheMenu</Filter>
</Text>
<Text Include="Alphabet\Normal\A.txt">
<Filter>Fichiers de ressources\Alphabet\Normal</Filter>
</Text>
<Text Include="AfficheMenu\Quitter.txt">
<Filter>Fichiers de ressources\AfficheMenu</Filter>
</Text>
<Text Include="TaxonLogo.txt">
<Filter>Fichiers de ressources\AfficheMenu</Filter>
</Text>
<Text Include="Alphabet\A.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\B.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\C.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\D.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\E.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\F.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\G.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\H.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\I.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\J.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\K.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\L.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\M.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\N.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\O.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\P.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\Q.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\R.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\S.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\T.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\U.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\V.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\W.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\X.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\Y.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Alphabet\Z.txt">
<Filter>Fichiers de ressources\Alphabet</Filter>
</Text>
<Text Include="Mots\mot3lettres.txt">
<Filter>Fichiers de ressources\Mots</Filter>
</Text>
<Text Include="Mots\mot4lettres.txt">
<Filter>Fichiers de ressources\Mots</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<None Include="README.md">

View File

@@ -6,6 +6,15 @@ DATE : 17 novembre 2025
BUT : Rassemble les appels de fonction de Taxon
====================================*/
/*
SCOREBOARD pour fichier en <20>criture
*/
//Librairies
#include <iostream>
#include <conio.h>
@@ -17,18 +26,22 @@ BUT : Rassemble les appels de fonction de Taxon
//D<>claration des namespaces
using namespace std;
//D<>claration du main
extern int nbEssai = 6;
extern int nbLettre = 4;
/*====================================
Tester que les lettres se r<>p<EFBFBD>tant fonctionnent.
====================================*/
int main() {
srand(time(NULL));
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE); //D<>claration de variable pour les images
bool quitter = false; //Quitter le jeu
int nbMot3lettre = 15; //Nombre de mot pr<70>sent dans le fichier
int temp = 0; //TODO: Variable temporaire
string motRandom; // Mot random
while (quitter == false) {
curseur(false);
backgroundDefault();
afficherMenu("AfficheMenu/Taxon.txt");
int choixMenu = _getch();
@@ -39,9 +52,8 @@ int main() {
delai();
curseur(true);
system("cls");
background(temp);
choisirMot("Mots/mot3lettres.txt", nbMot3lettre);
afficherMenuJouer();
effectuerTour();
break;
case '2':
@@ -49,14 +61,13 @@ int main() {
delai();
curseur(true);
system("cls");
temp = demanderBackground();
background(temp);
choixNbEssai();
choixLongeurMot();
break;
case '3':
afficherMenu("AfficheMenu/TaxonOption3.txt");
delai();
background('1');
afficherMenu("AfficheMenu/Quitter.txt");
quitter = true;
break;

View File

@@ -23,6 +23,9 @@ 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 int nbEssai;
extern int nbLettre;
/*====================================
MENU
@@ -39,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);
}
}
@@ -86,19 +90,32 @@ void curseur(bool interrupteur) {
/*====================================
1 - JOUER
====================================*/
//Fonction pour connaitre le nombre de ligne d'un fichier
int nombreLigneFichier(fstream& monFlux) {
string str;
int nbLigne = 0;
while (!monFlux.eof()) {
getline(monFlux, str);
nbLigne++;
}
monFlux.seekg(ios::beg);
return nbLigne;
}
//fonction pour choisir le mot de facon random
void choisirMot(string nomFichier, int maximum) {
system("cls");
int numeroLigne = rand() % (maximum)+1;
string choisirMot(string nomFichier) {//Choisi un mot al<61>atoire et le renvoi
fstream monFlux;
ouvrirFichier(monFlux, nomFichier);
string mot = goToLine(monFlux, numeroLigne);
int maximum = nombreLigneFichier(monFlux);
int numeroLigne = rand() % (maximum)+1;
string motRandom = goToLine(monFlux, numeroLigne);
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;
for (int i = 0; i < numeroLigne; i++) {
getline(monFlux, mot);
@@ -106,100 +123,218 @@ string goToLine(fstream& monFlux, int numeroLigne) {
return mot;
}
void afficherMenuJouer()
bool effectuerTour()
{
string motRandom;
int nbBonneLettre = 0;
if (nbLettre == 3) {
motRandom = choisirMot("Mots/mot3lettres.txt");
}
else if (nbLettre == 4) {
motRandom = choisirMot("Mots/mot4lettres.txt");
}
cout << setw(83) << "=============================================\n";
string motPlayer;
for (int i = 0; i < 6; i++)
for (int nbTentative = 0; nbTentative < nbEssai; nbTentative++)
{
do
{
cout << setw(65) << "Tentative #" << i + 1 << endl;
string lettrePlayer;
do {
cout << setw(69) << "Tentative des mots de " << nbLettre << " #" << nbTentative + 1 << endl;
cout << setw(69) << "Saisir votre mot : ";
cin >> motPlayer;
} while (motPlayer.length() > 3);
cin >> motPlayer; //TODO: mettre tolower string (boucle)
} while (motPlayer.length() != nbLettre);
if (dansListe(motPlayer))
nbBonneLettre = 0;
if (dansListe(motPlayer)) {
cout << setw(66) << "Votre mot est : " << motPlayer << endl;
for (int i = 0; i < nbLettre; i++) {
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];
afficherMotPlayer(lettrePlayer, MAUVAIS_PLACE);
}
else {
lettrePlayer = motPlayer[i];
afficherMotPlayer(lettrePlayer, PAS_LA);
}
}
if (nbBonneLettre == nbLettre)
{
afficherVictoire(motRandom);
return true;
}
else
{
cout << setw(58) << "Mot n'est pas dans la liste";
i--;
cout << endl;
}
}
else {
cout << setw(66) << "Votre mot est : " << motPlayer;
cout << endl << setw(75) << "Mot n'est pas dans la liste\n\n"; //TODO: Ajouter dans essai.txt
nbTentative--;
}
}
afficherDefaite(motRandom);
return false;
}
bool dansListe(string motPlayer)
{
bool dansListe(string motPlayer) {
fstream monFlux;
ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
comparerMot(monFlux, motPlayer, 15);
}
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne)
{
string mot;
for (int i = 0; i < numeroLigne; i++) {
getline(monFlux, mot);
int nbMots = 0;
if (nbLettre == 3) {
ouvrirFichier(monFlux, "Mots/mot3lettres.txt");
}
else if (nbLettre == 4) {
ouvrirFichier(monFlux, "Mots/mot4lettres.txt");
}
nbMots = nombreLigneFichier(monFlux);
for (int i = 0; i < nbMots; i++) {
getline(monFlux, mot); //TODO: Verification d'erreur du getline (Exemple si le fichier est trops petit)
if (motPlayer == mot)
{
fermerFichier(monFlux);
return true;
}
}
fermerFichier(monFlux);
return false;
}
int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i) {
int retour = PAS_LA;
for (int k = 0; k < nbLettre; k++) {
if (motRandom[k] == motPlayer[i] && i == k) {
return BONNE_PLACE;
}
else if ((motRandom[k] == motPlayer[i]) && i != k) {
retour = MAUVAIS_PLACE;
}
}
return retour;
}
//Affichage couleur des lettres
void afficherMotPlayer(string lettrePlayer, int positionLettre)
{
fstream monFlux;
string nomFichier;
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE); //Pour la couleur
lettrePlayer.insert(0, "Alphabet/");
lettrePlayer.append(".txt");
nomFichier = lettrePlayer;
ouvrirFichier(monFlux, nomFichier);
printLettre(monFlux, positionLettre);
fermerFichier(monFlux);
}
void printLettre(fstream& monFlux, int positionLettre)
{
int couleurLettre;
if (positionLettre == BONNE_PLACE)
{
couleurLettre = 10;
}
else if (positionLettre == MAUVAIS_PLACE)
{
couleurLettre = 06;
}
else if (positionLettre == PAS_LA)
{
couleurLettre = 8;
}
else
{
exit(2);
}
const char carre = 219;
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE); //D<>claration de variable pour les images
while (!monFlux.eof()) {
int val = 0;
monFlux >> val;
if (val == 00)
{
val = couleurLettre;
}
if (val == 99)
{
cout << endl;
}
else
{
SetConsoleTextAttribute(hconsole, val);
cout << carre << carre;
}
}
SetConsoleTextAttribute(hconsole, 15);
}
// Affichage victoire et d<>faite
void afficherVictoire(string motRandom) {
system("cls");
cout << "Felicitations, vous avez gagnez ! Le mot etais bien \"" << motRandom << "\" :D";
system("PAUSE>NUL");
}
void afficherDefaite(string motRandom) {
system("cls");
cout << "Dommage ! Meilleur chance la prochaine fois..."
<< endl
<< "Pour votre information, le mot a deviner etais \"" << motRandom << "\".";
system("PAUSE>NUL");
}
/*====================================
2 - OPTIONS
====================================*/
void background(int couleur) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
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."
<< endl
<< endl;
}
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);
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;
}
}
int demanderBackground() {
cout << "Choix";
int choix = _getche();
return choix;
}
void backgroundDefault() {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, 0x0F);
}

View File

@@ -24,14 +24,26 @@ void afficherImage(fstream& monFlux);
void fermerFichier(fstream& monFlux);
void delai();
void curseur(bool interrupteur);
void background(int couleur);
int demanderBackground();
void backgroundDefault();
int nombreLigneFichier(fstream& monFlux);
// Mot
void choisirMot(string nomFichier, int maximum);
string choisirMot(string nomFichier);
string goToLine(fstream& monFlux, int numeroLigne);
void afficherMenuJouer();
bool effectuerTour();
bool dansListe(string motPlayer);
bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne);
//bool comparerMot(fstream& monFlux, string motPlayer, int numeroLigne);
int lettreDansMot(string motRandom, string motPlayer, int nbLettre, int i);
void afficherMotPlayer(string lettrePlayer, int positionLettre);
void printLettre(fstream& monFlux, int positionLettre);
// Messages victoire et d<>faite
void afficherVictoire(string motRandom);
void afficherDefaite(string motRandom);
/*====================================
2 - OPTIONS
====================================*/
void choixNbEssai();
void choixLongeurMot();