Merge pull request 'Lea' (#1) from Lea into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
@@ -95,7 +95,7 @@ void initGrid(string grid[][LARGTIC]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8); //affiche les <20>mojis
|
||||||
string emoteUp,
|
string emoteUp,
|
||||||
emoteDown,
|
emoteDown,
|
||||||
emoteJ1,
|
emoteJ1,
|
||||||
@@ -180,53 +180,6 @@ void afficherImageTableau(std::string grid[][LARGTIC], std::string style) {
|
|||||||
SetConsoleOutputCP(codeConsole);
|
SetConsoleOutputCP(codeConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tourJoueur(string grid[][LARGTIC], int joueur) {
|
|
||||||
int verticale,
|
|
||||||
horizontale;
|
|
||||||
|
|
||||||
cout << "\n\nTour du joueur " << joueur << endl;
|
|
||||||
afficherImageTableau(grid, style);
|
|
||||||
|
|
||||||
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 (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) {
|
|
||||||
// V<>RIFIER LE CIN D'ERREUR!!!!!
|
|
||||||
cout << "\n\nVeuillez choisir une case vide.\n"
|
|
||||||
<< "\n\nEntrez une coordonnee verticale : ";
|
|
||||||
cin >> verticale;
|
|
||||||
cout << "\nEntrez une coordonnee horizontale : ";
|
|
||||||
cin >> horizontale;
|
|
||||||
|
|
||||||
verticale--;
|
|
||||||
horizontale--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (joueur == 1) {
|
|
||||||
grid[verticale][horizontale] = iconJ1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
grid[verticale][horizontale] = iconJ2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool verifFinMatch(std::string grid[][LARGTIC]) {
|
bool verifFinMatch(std::string grid[][LARGTIC]) {
|
||||||
bool fin = false;
|
bool fin = false;
|
||||||
@@ -308,6 +261,55 @@ void afficherFinMatch(string grid[][LARGTIC], int gagnant, int nbJoueurs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Joueur
|
||||||
|
void tourJoueur(string grid[][LARGTIC], int joueur) {
|
||||||
|
int verticale,
|
||||||
|
horizontale;
|
||||||
|
|
||||||
|
cout << "\n\nTour du joueur " << joueur << endl;
|
||||||
|
afficherImageTableau(grid, style);
|
||||||
|
|
||||||
|
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 (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) {
|
||||||
|
// V<>RIFIER LE CIN D'ERREUR!!!!!
|
||||||
|
cout << "\n\nVeuillez choisir une case vide.\n"
|
||||||
|
<< "\n\nEntrez une coordonnee verticale : ";
|
||||||
|
cin >> verticale;
|
||||||
|
cout << "\nEntrez une coordonnee horizontale : ";
|
||||||
|
cin >> horizontale;
|
||||||
|
|
||||||
|
verticale--;
|
||||||
|
horizontale--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (joueur == 1) {
|
||||||
|
grid[verticale][horizontale] = iconJ1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
grid[verticale][horizontale] = iconJ2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//1 joueur
|
//1 joueur
|
||||||
void jeuUnJoueur(string grid[][LARGTIC]) {
|
void jeuUnJoueur(string grid[][LARGTIC]) {
|
||||||
bool fin;
|
bool fin;
|
||||||
@@ -339,6 +341,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);
|
||||||
}
|
}
|
||||||
@@ -365,7 +368,7 @@ void jeuDeuxJoueurs(string grid[][LARGTIC]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Changer le th<74>me
|
//Changer le th<74>me
|
||||||
void changerLeTheme(bool& theme) {
|
void changerLeTheme() {
|
||||||
string grid[LARGTIC][LARGTIC];
|
string grid[LARGTIC][LARGTIC];
|
||||||
system("cls");
|
system("cls");
|
||||||
cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl;
|
cout << endl << "Changer le theme du jeu Tic Tac Toe" << endl;
|
||||||
@@ -379,9 +382,6 @@ void changerLeTheme(bool& theme) {
|
|||||||
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/themeDefaut.txt";
|
style = "themes/themeDefaut.txt";
|
||||||
@@ -483,4 +483,4 @@ void changerLeTheme(bool& theme) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (choix != 'Q');
|
} while (choix != 'Q');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,4 @@ 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(bool& theme);
|
void changerLeTheme();
|
||||||
@@ -13,7 +13,6 @@ using namespace std;
|
|||||||
int main() {
|
int main() {
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
|
||||||
bool theme = false;
|
|
||||||
char choix;
|
char choix;
|
||||||
string grid[LARGTIC][LARGTIC];
|
string grid[LARGTIC][LARGTIC];
|
||||||
|
|
||||||
@@ -23,28 +22,17 @@ int main() {
|
|||||||
|
|
||||||
switch (choix) {
|
switch (choix) {
|
||||||
case 'A':
|
case 'A':
|
||||||
if (theme == true) {
|
system("cls");
|
||||||
system("cls");
|
jeuUnJoueur(grid);
|
||||||
jeuUnJoueur(grid);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cout << "\n\nVeuillez choisir un theme d'abord.";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'B':
|
case 'B':
|
||||||
if (theme == true) {
|
system("cls");
|
||||||
system("cls");
|
jeuDeuxJoueurs(grid);
|
||||||
jeuDeuxJoueurs(grid);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cout << "\n\nVeuillez choisir un theme d'abord.";
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
changerLeTheme(theme);
|
changerLeTheme();
|
||||||
theme = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Q':
|
case 'Q':
|
||||||
|
|||||||
Reference in New Issue
Block a user