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