Compare commits

..

8 Commits

Author SHA1 Message Date
Sunny
b488389d8a TOUT MARRRRRCHE!!! 2025-12-05 10:45:49 -05:00
Lea
c928b9483d modification de la fonction partie nulle 2025-12-05 10:22:44 -05:00
Sunny
ffe4af9f93 Merge branch 'main' of https://gitea.zkd.ca/DEV_WEB/TicTacToe 2025-12-05 10:13:11 -05:00
Sunny
1d513239d2 WTF 2025-12-05 10:12:30 -05:00
Lea
d445cda491 wijhfkjdfns 2025-12-05 10:09:50 -05:00
Sunny
b991978b6d Idk, dude 2025-12-05 10:02:20 -05:00
Sunny
a72da69ea7 Work 2025-12-05 09:51:51 -05:00
Lea
008f2a3329 l'affichage de partie nulle fonctionne, mais le vainqueur est affiché comme étant joueur 9 2025-12-05 09:51:40 -05:00
2 changed files with 40 additions and 34 deletions

View File

@@ -28,7 +28,7 @@ char carre = 219, choix;
//<2F> faire : <20>galit<69> et entrer de coordonn<6E>e //<2F> faire : <20>galit<69> et entrer de coordonn<6E>e
//Fichiers //Fichiers
void ouvrirFichier(std::fstream& monFlux, std::string nomFichier) { void ouvrirFichier(std::fstream & monFlux, std::string nomFichier) {
monFlux.open(nomFichier, ios::in); monFlux.open(nomFichier, ios::in);
if (!monFlux) //On v<>rifie si le flux est "faux"/non fonctionnel. if (!monFlux) //On v<>rifie si le flux est "faux"/non fonctionnel.
{ {
@@ -38,7 +38,7 @@ void ouvrirFichier(std::fstream& monFlux, std::string nomFichier) {
} }
} }
void fermerFichier(std::fstream& monFlux) { void fermerFichier(std::fstream & monFlux) {
monFlux.close(); monFlux.close();
} }
@@ -63,7 +63,7 @@ void afficherMenu(char& choix) {
cout << endl; cout << endl;
} }
void afficherImageMenu(std::fstream& monFlux) { void afficherImageMenu(std::fstream & monFlux) {
int repet = 0; int repet = 0;
if (monFlux) { if (monFlux) {
while (!monFlux.eof()) { while (!monFlux.eof()) {
@@ -190,11 +190,10 @@ bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
return true; return true;
} }
else { else {
compteur++;
// Valide horizontales 00, 01, 02 || 10, 11, 12 || 20, 21, 22 // Valide horizontales 00, 01, 02 || 10, 11, 12 || 20, 21, 22
for (int i = 0; i < LARGTIC; i++) { for (int i = 0; i < LARGTIC; i++) {
fin = true; fin = true;
for (int j = 0; j < LARGTIC-1; j++) { for (int j = 0; j < LARGTIC - 1; j++) {
if (grid[i][j] == "") { if (grid[i][j] == "") {
fin = false; fin = false;
} }
@@ -214,12 +213,12 @@ bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
// Valide verticales 00, 10, 20 || 01, 11, 21 || 02, 12, 22 // Valide verticales 00, 10, 20 || 01, 11, 21 || 02, 12, 22
for (int i = 0; i < LARGTIC; i++) { for (int i = 0; i < LARGTIC; i++) {
fin = true; fin = true;
for (int j = 0; j < LARGTIC-1; j++) { for (int j = 0; j < LARGTIC - 1; j++) {
if (grid[j][i] == "") { if (grid[j][i] == "") {
fin = false; fin = false;
} }
else { else {
fin = fin && (grid[j][i] == grid[j+1][i]); fin = fin && (grid[j][i] == grid[j + 1][i]);
//cout << "comparaison de" << j << "," << i << " et " << j + 1 << "," << i << endl; //cout << "comparaison de" << j << "," << i << " et " << j + 1 << "," << i << endl;
} }
} }
@@ -276,23 +275,30 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
cout << "\n\nPartie nulle!"; cout << "\n\nPartie nulle!";
} }
} }
else {
if (gagnant == 3) { else if (nbJoueurs == 2){
cout << "\n\nPartie nulle!"; if (gagnant == 1) {
cout << "\n\nJoueur 1 a gagne la partie!";
}
else if (gagnant == 2) {
cout << "\n\nJoueur 2 a gagne la partie!";
} }
else { else {
cout << "\n\nLe joueur " << gagnant cout << "\n\nPartie nulle!";
<< " a gagne la partie!";
} }
} }
} }
int partieNulle(string grid[][LARGTIC], int compteur) { int partieNulle(string grid[][LARGTIC], int compteur) {
int max = LARGTIC * LARGTIC; int max = LARGTIC * LARGTIC;
int temp = gagnant;
if (compteur == max) { if (compteur == max) {
gagnant = 3; gagnant = 3;
return gagnant;
} }
else {
gagnant = temp;
}
return gagnant;
} }
// Joueur // Joueur
@@ -347,7 +353,6 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
//1 joueur //1 joueur
void jeuUnJoueur(string grid[][LARGTIC]) { void jeuUnJoueur(string grid[][LARGTIC]) {
bool fin; bool fin;
int gagnant;
int nbJoueurs = 1; int nbJoueurs = 1;
int compteur = 0; int compteur = 0;
@@ -356,15 +361,17 @@ void jeuUnJoueur(string grid[][LARGTIC]) {
do { do {
tourJoueur(grid, 1); tourJoueur(grid, 1);
gagnant = 1; gagnant = 1;
compteur++;
fin = verifFinMatch(grid, compteur); fin = verifFinMatch(grid, compteur);
gagnant = partieNulle(grid, compteur);
if (fin != true) { if (fin != true) {
tourOrdi(grid); tourOrdi(grid);
gagnant = 2; gagnant = 2;
system("PAUSE>nul"); system("PAUSE>nul");
compteur++;
fin = verifFinMatch(grid, compteur); fin = verifFinMatch(grid, compteur);
} }
} while (fin != true); } while (fin != true);
gagnant = partieNulle(grid, compteur);
afficherFinMatch(grid, gagnant, nbJoueurs); afficherFinMatch(grid, gagnant, nbJoueurs);
} }
@@ -385,7 +392,6 @@ void tourOrdi(string grid[][LARGTIC]) {
//2 joueurs //2 joueurs
void jeuDeuxJoueurs(string grid[][LARGTIC]) { void jeuDeuxJoueurs(string grid[][LARGTIC]) {
bool fin; bool fin;
int gagnant;
int nbJoueurs = 2; int nbJoueurs = 2;
int compteur = 0; int compteur = 0;
@@ -394,16 +400,16 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
do { do {
tourJoueur(grid, 1); tourJoueur(grid, 1);
gagnant = 1; gagnant = 1;
fin = verifFinMatch(grid, compteur);
compteur++; compteur++;
gagnant = partieNulle(grid, compteur); fin = verifFinMatch(grid, compteur);
if (fin != true) { if (fin != true) {
tourJoueur(grid, 2); tourJoueur(grid, 2);
gagnant = 2; gagnant = 2;
fin = verifFinMatch(grid, compteur);
compteur++; compteur++;
fin = verifFinMatch(grid, compteur);
} }
} while (fin != true); } while (fin != true);
gagnant = partieNulle(grid, compteur);
afficherFinMatch(grid, gagnant, nbJoueurs); afficherFinMatch(grid, gagnant, nbJoueurs);
} }