This commit is contained in:
Sunny
2025-12-05 10:12:30 -05:00

View File

@@ -28,7 +28,7 @@ char carre = 219, choix;
//<2F> faire : <20>galit<69> et entrer de coordonn<6E>e
//Fichiers
void ouvrirFichier(std::fstream& monFlux, std::string nomFichier) {
void ouvrirFichier(std::fstream & monFlux, std::string nomFichier) {
monFlux.open(nomFichier, ios::in);
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();
}
@@ -63,7 +63,7 @@ void afficherMenu(char& choix) {
cout << endl;
}
void afficherImageMenu(std::fstream& monFlux) {
void afficherImageMenu(std::fstream & monFlux) {
int repet = 0;
if (monFlux) {
while (!monFlux.eof()) {
@@ -186,16 +186,14 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
bool fin = false;
int max = LARGTIC * LARGTIC;
if (compteur == max) {
return true;
}
else {
compteur++;
// Valide horizontales 00, 01, 02 || 10, 11, 12 || 20, 21, 22
for (int i = 0; i < LARGTIC; i++) {
fin = true;
for (int j = 0; j < LARGTIC-1; j++) {
for (int j = 0; j < LARGTIC - 1; j++) {
if (grid[i][j] == "") {
fin = false;
}
@@ -215,12 +213,12 @@ bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
// Valide verticales 00, 10, 20 || 01, 11, 21 || 02, 12, 22
for (int i = 0; i < LARGTIC; i++) {
fin = true;
for (int j = 0; j < LARGTIC-1; j++) {
for (int j = 0; j < LARGTIC - 1; j++) {
if (grid[j][i] == "") {
fin = false;
}
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;
}
}
@@ -277,15 +275,6 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
cout << "\n\nPartie nulle!";
}
}
else {
if (gagnant == 3) {
cout << "\n\nPartie nulle!";
}
else {
cout << "\n\nLe joueur " << gagnant
<< " a gagne la partie!";
}
}
}
int partieNulle(string grid[][LARGTIC], int compteur) {
@@ -294,6 +283,10 @@ int partieNulle(string grid[][LARGTIC], int compteur) {
gagnant = 3;
return gagnant;
}
else {
gagnant = 1;
return gagnant;
}
}
// Joueur
@@ -348,7 +341,7 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
//1 joueur
void jeuUnJoueur(string grid[][LARGTIC]) {
bool fin;
int gagnant;
int gagnant = 1;
int nbJoueurs = 1;
int compteur = 0;
@@ -357,15 +350,17 @@ void jeuUnJoueur(string grid[][LARGTIC]) {
do {
tourJoueur(grid, 1);
gagnant = 1;
compteur++;
fin = verifFinMatch(grid, compteur);
gagnant = partieNulle(grid, compteur);
if (fin != true) {
tourOrdi(grid);
gagnant = 2;
system("PAUSE>nul");
compteur++;
fin = verifFinMatch(grid, compteur);
}
} while (fin != true);
gagnant = partieNulle(grid, compteur);
afficherFinMatch(grid, gagnant, nbJoueurs);
}
@@ -386,7 +381,7 @@ void tourOrdi(string grid[][LARGTIC]) {
//2 joueurs
void jeuDeuxJoueurs(string grid[][LARGTIC]) {
bool fin;
int gagnant;
int gagnant = 1;
int nbJoueurs = 2;
int compteur = 0;
@@ -395,14 +390,13 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
do {
tourJoueur(grid, 1);
gagnant = 1;
fin = verifFinMatch(grid, compteur);
compteur++;
fin = verifFinMatch(grid, compteur);
if (fin != true) {
tourJoueur(grid, 2);
gagnant = 2;
fin = verifFinMatch(grid, compteur);
compteur++;
fin = verifFinMatch(grid, compteur);
}
} while (fin != true);
gagnant = partieNulle(grid, compteur);