Compare commits
2 Commits
1a8a5dd8d7
...
00217eb38a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00217eb38a | ||
|
|
548c4ed27e |
@@ -183,10 +183,9 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -199,7 +198,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,14 +269,30 @@ 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 (gagnant == 3) {
|
||||||
|
cout << "\n\nPartie nulle!";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cout << "\n\nLe joueur " << gagnant
|
cout << "\n\nLe joueur " << gagnant
|
||||||
<< " a gagne la partie!";
|
<< " a gagne la partie!";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int partieNulle(string grid[][LARGTIC], int compteur) {
|
||||||
|
int max = LARGTIC * LARGTIC;
|
||||||
|
if (compteur == max) {
|
||||||
|
gagnant = 3;
|
||||||
|
return gagnant;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joueur
|
// Joueur
|
||||||
@@ -335,20 +349,20 @@ void jeuUnJoueur(string grid[][LARGTIC]) {
|
|||||||
bool fin;
|
bool fin;
|
||||||
int gagnant;
|
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);
|
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");
|
||||||
fin = verifFinMatch(grid);
|
fin = verifFinMatch(grid, compteur);
|
||||||
}
|
}
|
||||||
} while (fin != true);
|
} while (fin != true);
|
||||||
afficherFinMatch(grid, gagnant, nbJoueurs);
|
afficherFinMatch(grid, gagnant, nbJoueurs);
|
||||||
@@ -373,17 +387,21 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
|||||||
bool fin;
|
bool fin;
|
||||||
int gagnant;
|
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);
|
fin = verifFinMatch(grid, compteur);
|
||||||
|
compteur++;
|
||||||
|
gagnant = partieNulle(grid, compteur);
|
||||||
if (fin != true) {
|
if (fin != true) {
|
||||||
tourJoueur(grid, 2);
|
tourJoueur(grid, 2);
|
||||||
gagnant = 2;
|
gagnant = 2;
|
||||||
fin = verifFinMatch(grid);
|
fin = verifFinMatch(grid, compteur);
|
||||||
|
compteur++;
|
||||||
}
|
}
|
||||||
} while (fin != true);
|
} while (fin != true);
|
||||||
afficherFinMatch(grid, gagnant, nbJoueurs);
|
afficherFinMatch(grid, gagnant, nbJoueurs);
|
||||||
|
|||||||
@@ -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]);
|
||||||
|
|||||||
Reference in New Issue
Block a user