Compare commits

...

10 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
Sunny
00217eb38a Merge branch 'main' of https://gitea.zkd.ca/DEV_WEB/TicTacToe 2025-12-05 09:38:34 -05:00
Sunny
548c4ed27e confusion 2025-12-05 09:38:29 -05:00
3 changed files with 62 additions and 37 deletions

View File

@@ -183,15 +183,13 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
SetConsoleOutputCP(codeConsole); SetConsoleOutputCP(codeConsole);
} }
bool verifFinMatch(std::string grid[][LARGTIC]) { bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
bool fin = false; bool fin = false;
int max = LARGTIC * LARGTIC; int max = LARGTIC * LARGTIC;
int compteur = 0;
if (compteur == max) { if (compteur == max) {
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;
@@ -199,7 +197,6 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
if (grid[i][j] == "") { if (grid[i][j] == "") {
fin = false; fin = false;
} }
else { else {
fin = fin && (grid[i][j] == grid[i][j + 1]); fin = fin && (grid[i][j] == grid[i][j + 1]);
//cout << "comparaison de " << i << "," << j << " et " << i << "," << j+1 << endl; //cout << "comparaison de " << i << "," << j << " et " << i << "," << j+1 << endl;
@@ -271,15 +268,38 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
if (gagnant == 1) { if (gagnant == 1) {
cout << "\n\nLe joueur a gagne la partie!"; cout << "\n\nLe joueur a gagne la partie!";
} }
else { else if (gagnant == 2) {
cout << "\n\nL'ordinateur a gagne la partie!"; cout << "\n\nL'ordinateur a gagne la partie!";
} }
else {
cout << "\n\nPartie nulle!";
}
}
else if (nbJoueurs == 2){
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 max = LARGTIC * LARGTIC;
int temp = gagnant;
if (compteur == max) {
gagnant = 3;
}
else {
gagnant = temp;
}
return gagnant;
}
// Joueur // Joueur
void tourJoueur(string grid[][LARGTIC], int joueur) { void tourJoueur(string grid[][LARGTIC], int joueur) {
@@ -333,24 +353,25 @@ 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;
cout << "Un joueur a ete choisi. Le joueur joue en premier."; cout << "Un joueur a ete choisi. Le joueur joue en premier.";
//AJOUTER UN COMPTEUR DE TOURS POUR LES EXAEQUO!!!!!!
do { do {
tourJoueur(grid, 1); tourJoueur(grid, 1);
gagnant = 1; gagnant = 1;
fin = verifFinMatch(grid); compteur++;
fin = verifFinMatch(grid, compteur);
if (fin != true) { if (fin != true) {
tourOrdi(grid); tourOrdi(grid);
gagnant = 2; gagnant = 2;
system("PAUSE>nul"); system("PAUSE>nul");
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);
} }
@@ -371,21 +392,24 @@ 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;
cout << "\nDeux joueurs a ete choisi. Les tours seront l'un a la suite de l'autre.\n\n"; cout << "\nDeux joueurs a ete choisi. Les tours seront l'un a la suite de l'autre.\n\n";
do { do {
tourJoueur(grid, 1); tourJoueur(grid, 1);
gagnant = 1; gagnant = 1;
fin = verifFinMatch(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++;
fin = verifFinMatch(grid, compteur);
} }
} while (fin != true); } while (fin != true);
gagnant = partieNulle(grid, compteur);
afficherFinMatch(grid, gagnant, nbJoueurs); afficherFinMatch(grid, gagnant, nbJoueurs);
} }

View File

@@ -24,8 +24,9 @@ void afficherImageMenu(std::fstream& monFlux);
//G<>n<EFBFBD>ral //G<>n<EFBFBD>ral
void afficherImageTableau(std::string grid[][LARGTIC], std::string style); void afficherImageTableau(std::string grid[][LARGTIC], std::string style);
void tourJoueur(std::string grid[][LARGTIC], int joueur); //pour savoir quel icon utiliser void tourJoueur(std::string grid[][LARGTIC], int joueur); //pour savoir quel icon utiliser
bool verifFinMatch(std::string grid[][LARGTIC], int gagnant); bool verifFinMatch(std::string grid[][LARGTIC], int compteur);
void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs); void afficherFinMatch(std::string grid[][LARGTIC], int gagnant, int nbJoueurs);
int partieNulle(std::string grid[][LARGTIC], int compteur);
//1 joueur //1 joueur
void jeuUnJoueur(std::string grid[][LARGTIC]); void jeuUnJoueur(std::string grid[][LARGTIC]);