add cli interface

This commit is contained in:
Mylloon 2023-12-28 15:44:04 +01:00
parent cab56ad979
commit 6a6144e35e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,7 +1,9 @@
#include "../includes/Butin/PlateauButin.hpp"
#include "../includes/Dames/PlateauDames.hpp" #include "../includes/Dames/PlateauDames.hpp"
#include "../includes/Ecran.hpp" #include "../includes/Ecran.hpp"
#include "../includes/Safari/PlateauSafari.hpp"
void draw_debug(PlateauDames &p) { void draw_debug(Plateau &p) {
p.afficherPlateau(std::cout, false); p.afficherPlateau(std::cout, false);
} }
@ -9,13 +11,70 @@ void click_debug(const int x, const int y) {
std::cout << "Clic souris @ (" << x << ", " << y << ")\n"; std::cout << "Clic souris @ (" << x << ", " << y << ")\n";
} }
int main() { void help(char const *progName) {
Joueur j1; std::cout << "Menu d'aide de " << progName << "\n";
Joueur j2;
PlateauDames p(j1, j2); std::cout << "\t" << progName << " butin\n";
Ecran e; std::cout << "\t\t"
// e.afficher(std::bind(&draw_debug, p), click_debug); << "Lance le jeu \"Butin\"\n";
std::cout << "\t" << progName << " dames\n";
std::cout << "\t\t"
<< "Lance le jeu \"Dames\"\n";
std::cout << "\t" << progName << " safari\n";
std::cout << "\t\t"
<< "Lance le jeu \"Safari\"\n";
}
int main(int argc, char const *argv[]) {
Ecran e;
// Interface cli
if (argc >= 2) {
Joueur j1;
std::string arg = argv[1];
Plateau *p;
if (arg.compare("help") == 0) {
help(argv[0]);
return EXIT_SUCCESS;
}
else if (arg.compare("butin") == 0) {
Joueur j2;
p = new PlateauButin();
}
else if (arg.compare("dames") == 0) {
Joueur j2;
p = new PlateauDames(j1, j2);
}
else if (arg.compare("safari") == 0) {
Joueur j2;
Joueur j3; // demander à l'utilisateur
p = new PlateauSafari();
}
else {
std::cerr << "Jeu inconnu.\n";
help(argv[0]);
return EXIT_FAILURE;
}
e.afficher(std::bind(&draw_debug, std::ref(*p)), click_debug);
// Libère le plateau de la mémoire
delete p;
std::cout << "Merci d'avoir joué !" << std::endl;
} else {
// Interface graphique, menu de selection de jeu ?
help(argv[0]);
}
std::cout << "Good bye!" << std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }