Compare commits
8 Commits
00217eb38a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b488389d8a | ||
|
|
c928b9483d | ||
|
|
ffe4af9f93 | ||
|
|
1d513239d2 | ||
|
|
d445cda491 | ||
|
|
b991978b6d | ||
|
|
a72da69ea7 | ||
|
|
008f2a3329 |
@@ -190,7 +190,6 @@ bool verifFinMatch(std::string grid[][LARGTIC], int compteur) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
compteur++;
|
||||
// Valide horizontales 00, 01, 02 || 10, 11, 12 || 20, 21, 22
|
||||
for (int i = 0; i < LARGTIC; i++) {
|
||||
fin = true;
|
||||
@@ -276,23 +275,30 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
|
||||
cout << "\n\nPartie nulle!";
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (gagnant == 3) {
|
||||
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 {
|
||||
cout << "\n\nLe joueur " << gagnant
|
||||
<< " a gagne la partie!";
|
||||
cout << "\n\nPartie nulle!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int partieNulle(string grid[][LARGTIC], int compteur) {
|
||||
int max = LARGTIC * LARGTIC;
|
||||
int temp = gagnant;
|
||||
if (compteur == max) {
|
||||
gagnant = 3;
|
||||
return gagnant;
|
||||
}
|
||||
else {
|
||||
gagnant = temp;
|
||||
}
|
||||
return gagnant;
|
||||
}
|
||||
|
||||
// Joueur
|
||||
@@ -347,7 +353,6 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
|
||||
//1 joueur
|
||||
void jeuUnJoueur(string grid[][LARGTIC]) {
|
||||
bool fin;
|
||||
int gagnant;
|
||||
int nbJoueurs = 1;
|
||||
int compteur = 0;
|
||||
|
||||
@@ -356,15 +361,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);
|
||||
}
|
||||
|
||||
@@ -385,7 +392,6 @@ void tourOrdi(string grid[][LARGTIC]) {
|
||||
//2 joueurs
|
||||
void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
||||
bool fin;
|
||||
int gagnant;
|
||||
int nbJoueurs = 2;
|
||||
int compteur = 0;
|
||||
|
||||
@@ -394,16 +400,16 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
||||
do {
|
||||
tourJoueur(grid, 1);
|
||||
gagnant = 1;
|
||||
fin = verifFinMatch(grid, compteur);
|
||||
compteur++;
|
||||
gagnant = partieNulle(grid, 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);
|
||||
afficherFinMatch(grid, gagnant, nbJoueurs);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user