diff --git a/TicTacToe/0 b/TicTacToe/0 index ba64bff..6fe9972 100644 --- a/TicTacToe/0 +++ b/TicTacToe/0 @@ -1 +1 @@ -Press any key to continue . . . \ No newline at end of file +Press any key to continue . . . diff --git a/TicTacToe/fonctions.cpp b/TicTacToe/fonctions.cpp index dda798d..a0ac649 100644 --- a/TicTacToe/fonctions.cpp +++ b/TicTacToe/fonctions.cpp @@ -15,9 +15,9 @@ BUT : Fichier de fonctions Tic Tac Toe using namespace std; extern const int LARGTIC; - string ICONJ1 = "X"; - string ICONJ2 = "O"; - string style = "themes/themeSea.txt"; +string ICONJ1 = "X"; +string ICONJ2 = "O"; +string style = "themes/themeSea.txt"; int codeConsole = 0; fstream monFlux; @@ -175,10 +175,26 @@ void tourJoueur(string grid[][LARGTIC], int joueur) { cout << "\n\nEntrez une coordonnee verticale : "; cin >> verticale; + + while (verticale < 1 || verticale > 3) { + cout << "\n\nVeuillez entrer une donnee valide.\n" + << "\n\nEntrez une coordonnee verticale : "; + cin >> verticale; + } + cout << "\nEntrez une coordonnee horizontale : "; cin >> horizontale; - while (grid[verticale - 1][horizontale - 1] == ICONJ1 || grid[verticale - 1][horizontale - 1] == ICONJ2) { + while (horizontale < 1 || horizontale > 3) { + cout << "\n\nVeuillez entrer une donnee valide.\n" + << "\n\nEntrez une coordonnee horizontale : "; + cin >> horizontale; + } + + verticale -= 1; + horizontale -= 1; + + while (grid[verticale][horizontale] == ICONJ1 || grid[verticale][horizontale] == ICONJ2) { cout << "\n\nVeuillez choisir une case vide.\n" << "\n\nEntrez une coordonnee verticale : "; cin >> verticale; @@ -321,10 +337,11 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) { tourJoueur(grid, 1); gagnant = 1; fin = verifFinMatch(grid); - tourJoueur(grid, 2); - gagnant = 2; - fin = verifFinMatch(grid); - // la condition doit être une série de 3 symboles pareil + if (fin != true) { + tourJoueur(grid, 2); + gagnant = 2; + fin = verifFinMatch(grid); + } } while (fin != true); afficherFinMatch(grid, gagnant, nbJoueurs); }