modification des modifications de résolution de problèmes

This commit is contained in:
Lea
2025-11-28 08:42:36 -05:00
parent b7dae93147
commit 370b31ce46
3 changed files with 27 additions and 19 deletions

View File

@@ -15,8 +15,8 @@ BUT : Fichier de fonctions Tic Tac Toe
using namespace std; using namespace std;
extern const int LARGTIC; extern const int LARGTIC;
string ICONJ1 = "X"; string iconJ1 = "X";
string ICONJ2 = "O"; string iconJ2 = "O";
string style = "themes/themeSea.txt"; string style = "themes/themeSea.txt";
int codeConsole = 0; int codeConsole = 0;
@@ -90,15 +90,15 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
SetConsoleOutputCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8);
string emoteUp, string emoteUp,
emoteDown, emoteDown,
iconJ1, emoteJ1,
iconJ2; emoteJ2;
// Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!! // Faire une fonction pour retenir le th<74>me s<>lectionn<6E> par le joueur!!!!
ouvrirFichier(monFlux, style); ouvrirFichier(monFlux, style);
if (monFlux) { if (monFlux) {
while (!monFlux.eof()) { while (!monFlux.eof()) {
monFlux >> emoteUp >> emoteDown >> ICONJ1 >> ICONJ2; monFlux >> emoteUp >> emoteDown >> emoteJ1 >> emoteJ2;
} }
monFlux.close(); monFlux.close();
cout << endl; cout << endl;
@@ -132,12 +132,13 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
cout << " "; cout << " ";
} }
cout << " ";
} }
cout << "|" << endl << " " << k + 1 << " "; cout << "|" << endl << " " << k + 1 << " ";
for (int i = 0; i < LARGTIC; i++) { for (int i = 0; i < LARGTIC; i++) {
cout << "|" << " " ; cout << "|" << " ";
if (grid[k][i] == "X") { if (grid[k][i] == "X") {
cout << emoteJ1; cout << emoteJ1;
} }
@@ -156,6 +157,7 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
cout << " "; cout << " ";
} }
cout << " ";
} }
cout << "|" << endl << " "; cout << "|" << endl << " ";
@@ -198,20 +200,23 @@ void tourJoueur(string grid[][LARGTIC], int joueur) {
verticale -= 1; verticale -= 1;
horizontale -= 1; horizontale -= 1;
while (grid[verticale][horizontale] == ICONJ1 || grid[verticale][horizontale] == ICONJ2) { while (grid[verticale][horizontale] == iconJ1 || grid[verticale][horizontale] == iconJ2) {
// V<>RIFIER LE CIN D'ERREUR!!!!! // V<>RIFIER LE CIN D'ERREUR!!!!!
cout << "\n\nVeuillez choisir une case vide.\n" cout << "\n\nVeuillez choisir une case vide.\n"
<< "\n\nEntrez une coordonnee verticale : "; << "\n\nEntrez une coordonnee verticale : ";
cin >> verticale; cin >> verticale;
cout << "\nEntrez une coordonnee horizontale : "; cout << "\nEntrez une coordonnee horizontale : ";
cin >> horizontale; cin >> horizontale;
verticale--;
horizontale--;
} }
if (joueur == 1) { if (joueur == 1) {
grid[verticale][horizontale] = ICONJ1; grid[verticale][horizontale] = iconJ1;
} }
else { else {
grid[verticale][horizontale] = ICONJ2; grid[verticale][horizontale] = iconJ2;
} }
} }
@@ -222,7 +227,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
fin = true; fin = true;
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
if (grid[i][j] == " ") { if (grid[i][j] == "") {
fin = false; fin = false;
} }
@@ -238,7 +243,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
fin = true; fin = true;
for (int j = 0; j < 2; j++) { for (int j = 0; j < 2; j++) {
if (grid[i][j] == " ") { if (grid[i][j] == "") {
fin = false; fin = false;
} }
else { else {
@@ -252,7 +257,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
// Valide diagonale de 00, 11, 22 // Valide diagonale de 00, 11, 22
fin = true; fin = true;
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
if (grid[i][i] == " ") { if (grid[i][i] == "") {
fin = false; fin = false;
} }
else { else {
@@ -266,7 +271,7 @@ bool verifFinMatch(std::string grid[][LARGTIC]) {
// Valide diagonale 02, 11, 20 // Valide diagonale 02, 11, 20
fin = true; fin = true;
for (int i = 2; i > 0; i--) { for (int i = 2; i > 0; i--) {
if (grid[i][i] == " ") { if (grid[i][i] == "") {
fin = false; fin = false;
} }
else { else {
@@ -326,7 +331,7 @@ void tourOrdi(string grid[][LARGTIC]) {
vertical = rand() % (3); vertical = rand() % (3);
horizontal = rand() % (3); horizontal = rand() % (3);
} while (grid[vertical][horizontal] != ""); } while (grid[vertical][horizontal] != "");
grid[vertical][horizontal] = ICONJ2; grid[vertical][horizontal] = iconJ2;
afficherImageTableau(grid, style); afficherImageTableau(grid, style);
} }
@@ -352,7 +357,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
} }
//Changer le th<74>me //Changer le th<74>me
void changerLeTheme() { void changerLeTheme(bool& theme) {
string grid[LARGTIC][LARGTIC]; string grid[LARGTIC][LARGTIC];
system("cls"); system("cls");
do { do {
@@ -364,6 +369,9 @@ void changerLeTheme() {
choix = toupper(_getche()); choix = toupper(_getche());
cout << endl; cout << endl;
if (choix >= 'A' && choix <= 'D') {
theme = true;
}
switch (choix) { switch (choix) {
case 'A': case 'A':
style = "themes/themeSea.txt"; style = "themes/themeSea.txt";

View File

@@ -35,5 +35,5 @@ void tourOrdi(std::string grid[][LARGTIC]);
void jeuDeuxJoueurs(std::string grid[][LARGTIC]); void jeuDeuxJoueurs(std::string grid[][LARGTIC]);
//Changer le th<74>me //Changer le th<74>me
void changerLeTheme(); void changerLeTheme(bool &theme);

View File

@@ -57,6 +57,6 @@ int main() {
cout << endl << "Saisissez un choix valide." << endl; cout << endl << "Saisissez un choix valide." << endl;
break; break;
} }
system("PAUSE>0"); system("PAUSE>nul");
} while (choix != 'Q'); } while (choix != 'Q');
} }