modif tour ordinateur et correction de la fonction de vérification de fin de match
This commit is contained in:
@@ -17,6 +17,7 @@ using namespace std;
|
|||||||
extern const int LARGTIC;
|
extern const int LARGTIC;
|
||||||
const string ICONJ1 = { "X" };
|
const string ICONJ1 = { "X" };
|
||||||
const string ICONJ2 = { "O" };
|
const string ICONJ2 = { "O" };
|
||||||
|
int codeConsole = 0;
|
||||||
|
|
||||||
fstream monFlux;
|
fstream monFlux;
|
||||||
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE hconsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
@@ -40,6 +41,7 @@ void fermerFichier(std::fstream& monFlux) {
|
|||||||
//Menu
|
//Menu
|
||||||
void afficherMenu(char& choix) {
|
void afficherMenu(char& choix) {
|
||||||
system("cls");
|
system("cls");
|
||||||
|
codeConsole = GetConsoleOutputCP();
|
||||||
//T I C T A C T O E
|
//T I C T A C T O E
|
||||||
ouvrirFichier(monFlux, "menuTitre.txt");
|
ouvrirFichier(monFlux, "menuTitre.txt");
|
||||||
afficherImageMenu(monFlux);
|
afficherImageMenu(monFlux);
|
||||||
@@ -88,6 +90,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) {
|
|||||||
string emoteUp,
|
string emoteUp,
|
||||||
emoteLine,
|
emoteLine,
|
||||||
emoteDown;
|
emoteDown;
|
||||||
|
// Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!!
|
||||||
ouvrirFichier(monFlux, "themes/themeSea.txt");
|
ouvrirFichier(monFlux, "themes/themeSea.txt");
|
||||||
if (monFlux) {
|
if (monFlux) {
|
||||||
while (!monFlux.eof()) {
|
while (!monFlux.eof()) {
|
||||||
@@ -102,6 +105,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) {
|
|||||||
}
|
}
|
||||||
fermerFichier(monFlux);
|
fermerFichier(monFlux);
|
||||||
|
|
||||||
|
// Lignes de code pour faire afficher le Tic Tac Toe une fois que les symboles ont <20>t<EFBFBD> ajout<75>s
|
||||||
cout << " ";
|
cout << " ";
|
||||||
for (int i = 0; i < LARGTIC; i++) {
|
for (int i = 0; i < LARGTIC; i++) {
|
||||||
cout << " " << i + 1 << " ";
|
cout << " " << i + 1 << " ";
|
||||||
@@ -147,7 +151,7 @@ void afficherImageTableau(std::string grid[][LARGTIC]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
SetConsoleOutputCP(codeConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tourJoueur(string grid[][LARGTIC], int joueur) {
|
void tourJoueur(string grid[][LARGTIC], int joueur) {
|
||||||
@@ -171,7 +175,7 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool verifFinMatch(std::string grid[][LARGTIC]) {
|
bool verifFinMatch(std::string grid[][LARGTIC]) {
|
||||||
bool fin = true;
|
bool fin = false;
|
||||||
// Valide horizontales
|
// Valide horizontales
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
fin = true;
|
fin = true;
|
||||||
@@ -202,6 +206,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valide diagonale 02, 11, 20
|
// Valide diagonale 02, 11, 20
|
||||||
|
fin = true;
|
||||||
for (int i = 2; i > 0; i--) {
|
for (int i = 2; i > 0; i--) {
|
||||||
fin = fin && grid[i][i] == grid[i - 1][i - 1];
|
fin = fin && grid[i][i] == grid[i - 1][i - 1];
|
||||||
if (fin == true) {
|
if (fin == true) {
|
||||||
@@ -217,20 +222,24 @@ void jeuUnJoueur(string grid[][LARGTIC]) {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
tourJoueur(grid, 1);
|
tourJoueur(grid, 1);
|
||||||
|
//fin = verifFinMatch(grid);
|
||||||
tourOrdi(grid);
|
tourOrdi(grid);
|
||||||
system("PAUSE>0");
|
system("PAUSE>0");
|
||||||
fin = verifFinMatch(grid);
|
fin = verifFinMatch(grid);
|
||||||
} while (fin = true);
|
} while (fin != true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tourOrdi(string grid[][LARGTIC]) {
|
void tourOrdi(string grid[][LARGTIC]) {
|
||||||
int vertical = rand() % (3);
|
int vertical;
|
||||||
int horizontal = rand() % (3);
|
int horizontal;
|
||||||
|
|
||||||
cout << "\n\nTour de l'ordinateur" << endl;
|
cout << "\n\nTour de l'ordinateur" << endl;
|
||||||
afficherImageTableau(grid);
|
do {
|
||||||
|
vertical = rand() % (3);
|
||||||
|
horizontal = rand() % (3);
|
||||||
|
} while (grid[vertical][horizontal] != " ");
|
||||||
grid[vertical][horizontal] = ICONJ2;
|
grid[vertical][horizontal] = ICONJ2;
|
||||||
|
afficherImageTableau(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//2 joueurs
|
//2 joueurs
|
||||||
@@ -242,6 +251,6 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
|||||||
tourJoueur(grid, 1);
|
tourJoueur(grid, 1);
|
||||||
tourJoueur(grid, 2);
|
tourJoueur(grid, 2);
|
||||||
fin = verifFinMatch(grid);
|
fin = verifFinMatch(grid);
|
||||||
// la condition doit <20>tre une s<>rie de 3 chiffres
|
// la condition doit <20>tre une s<>rie de 3 symboles pareil
|
||||||
} while (fin = true);
|
} while (fin != true);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user