From bf6e5832111316f45b24e9a709cb50e44084c894 Mon Sep 17 00:00:00 2001 From: clementineob Date: Sat, 20 Dec 2025 17:26:44 +0100 Subject: [PATCH 1/2] ajout variantes --- .qtcreator/CMakeLists.txt.user | 318 +++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- generateAllHexFantome() | 0 include/Cite.hpp | 9 +- include/Jeu.hpp | 12 +- include/UI/StartMenu.hpp | 8 +- src/Cite.cpp | 52 +++++- src/Jeu.cpp | 36 +++- src/UI/StartMenu.cpp | 55 +++++- src/UI/mainwindow.cpp | 2 +- src/main.cpp | 10 +- 11 files changed, 467 insertions(+), 37 deletions(-) create mode 100644 .qtcreator/CMakeLists.txt.user create mode 100644 generateAllHexFantome() diff --git a/.qtcreator/CMakeLists.txt.user b/.qtcreator/CMakeLists.txt.user new file mode 100644 index 0000000..55e414b --- /dev/null +++ b/.qtcreator/CMakeLists.txt.user @@ -0,0 +1,318 @@ + + + + + + EnvironmentId + {52302327-6205-4ea2-a0c9-c36a7d74f403} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + true + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 0 + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 4 + true + + + + true + + 0 + + + + ProjectExplorer.Project.Target.0 + + Desktop + true + Desktop Qt 6.10.1 MinGW 64-bit + Desktop Qt 6.10.1 MinGW 64-bit + qt.qt6.6101.win64_mingw_kit + 0 + 0 + 0 + + Debug + 2 + false + + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DQT_MAINTENANCE_TOOL:FILEPATH=C:/Qt/MaintenanceTool.exe +-DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DCMAKE_BUILD_TYPE:STRING=Debug + 0 + C:\Users\cleme\Desktop\Cours\GI03\LO21\projet\Akropolis.cpp\build\Desktop_Qt_6_10_1_MinGW_64_bit-Debug + + + + + all + + false + + true + Compiler + CMakeProjectManager.MakeStep + + 1 + Compiler + Compiler + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + Compiler + CMakeProjectManager.MakeStep + + 1 + Nettoyer + Nettoyer + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + CMakeProjectManager.CMakeBuildConfiguration + 0 + 0 + + + 0 + Déploiement + Déploiement + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + + + false + + true + Compiler + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Installer le paquet Application Manager + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Déploiement + Déploiement + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + + false + + false + + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + CMakeProjectManager.CMakeRunConfiguration. + Akropolis + false + + true + true + true + %{RunConfig:Executable:Path} + + 1 + + 1 + + + 0 + Déploiement + Déploiement + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + + + + + + + + false + + true + Compiler + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Installer le paquet Application Manager + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Déploiement + Déploiement + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + CMakeProjectManager.CMakeRunConfiguration. + Akropolis + false + + true + true + true + %{RunConfig:Executable:Path} + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + Version + 22 + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 81e108f..e728887 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,4 +111,4 @@ if(WIN32) "${QT_ROOT_DIR}/plugins/platforms/qwindows.dll" "$/platforms/" ) -endif() \ No newline at end of file +endif() diff --git a/generateAllHexFantome() b/generateAllHexFantome() new file mode 100644 index 0000000..e69de29 diff --git a/include/Cite.hpp b/include/Cite.hpp index 46265fb..ce73fb3 100644 --- a/include/Cite.hpp +++ b/include/Cite.hpp @@ -3,6 +3,7 @@ #include #include #include +#include class Tuile; @@ -25,7 +26,7 @@ class Cite { - virtual uint32_t compterPoints( int niveau_difficulte=0) const = 0; + virtual uint32_t compterPoints( int niveau_difficulte=0, std::array variantes = {}) const = 0; virtual void afficher() const =0; void QTDraw() const; @@ -47,7 +48,6 @@ class Cite { protected: std::vector tuiles; - static void print_hex(Hexagone*hex, int x, int y, strCalc& calc); static void increase_calc_size_H(strCalc& calc, uint32_t size); static void increase_calc_size_V(strCalc& calc, uint32_t size); @@ -70,10 +70,11 @@ class CiteJoueur : public Cite { ~CiteJoueur()=default; bool placerTuileFromHexRef(Hexagone* hex) override; - uint32_t compterPoints( int niveau_difficulte=0) const override; + uint32_t compterPoints( int niveau_difficulte=0, std::array variantes = {}) const override; void afficher()const override; void addTuile(Tuile* t); + }; class CiteIllu : public Cite{ @@ -81,7 +82,7 @@ class CiteIllu : public Cite{ public: CiteIllu(const Tuile* tuileDeDepart):Cite(tuileDeDepart){}; - uint32_t compterPoints( int niveau_difficulte=0) const override; + uint32_t compterPoints( int niveau_difficulte=0, std::array variantes = {}) const override; bool placerTuileFromHexRef(Hexagone* hex)override{return false; }; void afficher()const override; private: diff --git a/include/Jeu.hpp b/include/Jeu.hpp index dd07fda..69db799 100755 --- a/include/Jeu.hpp +++ b/include/Jeu.hpp @@ -32,16 +32,15 @@ class Jeu { void afficherTuiles() const; void afficherHexagones() const; - void tourJoueur(Joueur* joueur); - void tourIllu(Illu* illu); // FONCTIONNES AFFICHAGE PARTIE EN MODE CONSOLE void StartMenuC(); - + void tourJoueur(Joueur* joueur); + void tourIllu(Illu* illu); // FONCTIONS APPELLES PAR QT ET CONSOLE: - void InitialiserPartie(const std::vector& names, uint32_t difficultyLevel); + void InitialiserPartie(const std::vector& names, uint32_t difficultyLevel, std::arrayvariantes={}); //void setDifficultyLevel(uint32_t level) { difficultyLevel = level; } //uint32_t getDifficultyLevel() const { return difficultyLevel; } @@ -98,9 +97,10 @@ class Jeu { bool QtDisplay = true; int nombreTuilesChantier; - int niveauDeDifficulte; + int niveauDeDifficulte; + std::array variantes; }; -#endif //JEU_H \ No newline at end of file +#endif //JEU_H diff --git a/include/UI/StartMenu.hpp b/include/UI/StartMenu.hpp index ef890c2..1a81fe5 100644 --- a/include/UI/StartMenu.hpp +++ b/include/UI/StartMenu.hpp @@ -6,6 +6,7 @@ #include "UI/GamePushButton.hpp" #include #include +#include class StartMenu : public QWidget { Q_OBJECT @@ -13,7 +14,7 @@ class StartMenu : public QWidget { StartMenu(QWidget* parent = nullptr); ~StartMenu() override; signals: - void playerSelectionConfirmed(std::vector players, uint32_t difficultyLevel); + void playerSelectionConfirmed(std::vector players, uint32_t difficultyLevel, std::arrayvariantes); private slots: void onConfirmClicked(); @@ -28,8 +29,9 @@ private slots: QComboBox* dificultyComboBox; - + QVBoxLayout* variantesLayout; uint32_t playerCount; uint32_t dificultyLevel; + std::array variantes; std::vector playerButtons; -}; \ No newline at end of file +}; diff --git a/src/Cite.cpp b/src/Cite.cpp index c71a9c0..453c481 100644 --- a/src/Cite.cpp +++ b/src/Cite.cpp @@ -561,7 +561,7 @@ bool CiteJoueur::placerTuileFromHexRef(Hexagone *hex) // updateFantomeOfTuile(tl); } -uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const +uint32_t CiteJoueur::compterPoints( int niveau_difficulte, std::arrayvariantes) const { uint32_t nb_place_bleue = 0; uint32_t nb_place_rouge = 0; @@ -635,6 +635,7 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const { const std::array voisins = h->getVoisins3D(); bool cond = true; + int var = 1; for (int i = 0; i < 6; i++) { @@ -646,8 +647,20 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const } } } - if (cond == true) - points_jaune += 1 * niveau; + //variante si on a une place jaune, on double les points + if(variantes[0]==1){ + for (int i = 0; i < 6; i++){ + if (voisins[i] != nullptr){ + if (voisins[i]->getCouleur() == Couleur::Jaune && voisins[i]->getType() == Type::Place){ + var=2; + } + } + } + } + if (cond == true) points_jaune += 1 * niveau * var; + + + } // calcul points jardins : +1 pt pour chaque jardin if (h->getCouleur() == Couleur::Vert) @@ -659,6 +672,7 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const { const std::array &voisins = h->getVoisins3D(); + int var =1; // on vérifie si entierment entouré au niveau 0 bool cond = true; @@ -674,8 +688,9 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const cond = false; } } + if(variantes[2]==1) var = niveau; if (cond) - points_violet += 1 * niveau; + points_violet += 1 * niveau * var; } // calcul habitation: on doit calculer les groupes d'habitations if (h->getCouleur() == Couleur::Bleu) @@ -718,7 +733,7 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const { bool cond = false; const std::array &voisins = h->getVoisins3D(); - + int var = 1; for (int i = 0; i < 6; i++) { if (voisins[i] != nullptr) @@ -731,8 +746,24 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const cond = true; } } - if (cond) - points_rouge += 1 * niveau; + if(variantes[4]==1){ + int cases_vides = 0; + for (int i = 0; i < 6; i++){ + if (voisins[i] != nullptr){ + if (voisins[i]->getType() == Type::Fantome) + cases_vides++; + } + else + { + cases_vides++; + } + + } + if(cases_vides>=3){ + var = 2; + } + } + if (cond) points_rouge += 1 * niveau * var; } } } @@ -748,6 +779,11 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte) const if (!habitations_visitees.empty()) { points_bleu = *std::max_element(points_hab.begin(), points_hab.end()); + if(variantes[3]==1){ + if(points_bleu>=10){ + points_bleu=points_bleu*2; + } + } } //std::cout << "printing points : " << points_bleu * nb_place_bleue * 1 << " . " << points_jaune * nb_place_jaune * 2 << " . " << points_rouge * nb_place_rouge * 2 << " . " << points_vert * nb_place_verte * 3 << " . " << points_violet * nb_place_violet * 2 << std::endl; @@ -869,7 +905,7 @@ void Cite::release_hex_fantome() } hexs_fantome.clear(); }; -uint32_t CiteIllu::compterPoints( int niveau_difficulte) const { +uint32_t CiteIllu::compterPoints( int niveau_difficulte, std::array variantes) const { uint32_t nb_carriere = 0; diff --git a/src/Jeu.cpp b/src/Jeu.cpp index 7db8467..90ecf19 100755 --- a/src/Jeu.cpp +++ b/src/Jeu.cpp @@ -145,7 +145,8 @@ Jeu::Jeu() : mode(ModeDeJeu::Solo), niveauDeDifficulte(0), pioche(*this) void Jeu::StartMenuC() { std::vector names; - + std::array variantes; + std::cout << "\n=============================" << std::endl; std::cout << "Bienvenue sur Akropolis.cpp !" << std::endl; std::cout << "=============================" << std::endl @@ -156,6 +157,32 @@ void Jeu::StartMenuC() std::cout << "Une partie est sur le point de commencer, combien êtes-vous : "; std::cin >> nJoueur; + int index_variante =0; + std::cout<<"Voici les differentes variantes disponibles : "<>reponse; + while (reponse != 'n' && reponse != 'N') + { + + do{ + cout<<"Quelle variante voulez vous ajoutez ? "; + std::cin>>index_variante; + if (index_variante < 0 || index_variante> 2){ + std::cout << "Numero de variante invalide. Dois être compris entre 0 et 4" << std::endl; + } + } while (index_variante < 0 || index_variante> 2); + variantes[index_variante] = 1; + cout<<"Merci. Cette variable a ete ajoute. En voulez vous d'autres ? o/n "; + cin>>reponse; + } + for (int i = 0; i < nJoueur; i++) { @@ -189,14 +216,15 @@ void Jeu::StartMenuC() } while (this->niveauDeDifficulte < 0 || this->niveauDeDifficulte > 2); } - j->InitialiserPartie(names, this->niveauDeDifficulte); // difficulté 0 par défaut en mode console + j->InitialiserPartie(names, this->niveauDeDifficulte,variantes); // difficulté 0 par défaut en mode console } -void Jeu::InitialiserPartie(const std::vector &names, uint32_t difficultyLevel) +void Jeu::InitialiserPartie(const std::vector &names, uint32_t difficultyLevel, std::array variantes) { std::cout << "\n--- Initialisation de la partie ---\n"; nombreTuilesChantier = names.size() + 2; niveauDeDifficulte = difficultyLevel; + this->variantes = variantes; for (size_t i = 0; i < names.size(); i++) { @@ -305,7 +333,7 @@ void Jeu::Lancer() for (auto &j : joueurs) { std::cout << j->getNom() << " : "; - std::cout << j->getCite()->compterPoints(niveauDeDifficulte) << " points" << std::endl; + std::cout << j->getCite()->compterPoints(niveauDeDifficulte, variantes) << " points" << std::endl; } } diff --git a/src/UI/StartMenu.cpp b/src/UI/StartMenu.cpp index 8a626a4..8946e78 100644 --- a/src/UI/StartMenu.cpp +++ b/src/UI/StartMenu.cpp @@ -3,16 +3,16 @@ #include #include #include - +#include #include StartMenu::StartMenu(QWidget* parent) : QWidget(parent), layout(new QVBoxLayout(this)), decBtn(new QPushButton("Enlever joueurs")), incBtn(new QPushButton("Ajouter joueurs")), - confirmBtn(new GamePushButton("Confirmer")), playerCount(1), dificultyLevel(0), + confirmBtn(new GamePushButton("Confirmer")), playerCount(1), dificultyLevel(0),variantes({}), lineEditLayout(new QVBoxLayout()), countInput(new QLineEdit()), - dificultyComboBox(new QComboBox()) + dificultyComboBox(new QComboBox()), variantesLayout(new QVBoxLayout) { QHBoxLayout* btnLayout = new QHBoxLayout(); @@ -32,6 +32,8 @@ StartMenu::StartMenu(QWidget* parent) incBtn->setFixedWidth(120); decBtn->setFixedWidth(120); + + // Ligne de difficulté (label + combobox) QWidget* difficultyRow = new QWidget(); QHBoxLayout* diffLayout = new QHBoxLayout(difficultyRow); @@ -42,6 +44,23 @@ StartMenu::StartMenu(QWidget* parent) dificultyComboBox->addItem("Métagénès (niveau Moyen)"); dificultyComboBox->addItem("Callicratès (niveau Difficile)"); + + //Selection de variantes (label + checks boxs) + QLabel* var = new QLabel("Variantes règles : "); + QCheckBox* marche = new QCheckBox("Variante marché"); + //QCheckBox* jardin = new QCheckBox("Variante jardin NON DISPO"); + QCheckBox* temple = new QCheckBox("Variante temple"); + QCheckBox* habitations = new QCheckBox("Variante habitations"); + QCheckBox* caserne = new QCheckBox("Variante caserne"); + + + variantesLayout->addWidget(var); + variantesLayout->addWidget(marche); + //variantesLayout->addWidget(jardin); //NON DISPO + variantesLayout->addWidget(temple); + variantesLayout->addWidget(habitations); + variantesLayout->addWidget(caserne); + connect(dificultyComboBox, &QComboBox::currentIndexChanged, this, [this](int index) { dificultyLevel = static_cast(index); }); @@ -103,6 +122,29 @@ StartMenu::StartMenu(QWidget* parent) } }); + //connexion des check box avec variantes + connect(marche, &QCheckBox::toggled, this, [this](bool checked) { + variantes[0] = checked ? 1 : 0; + }); + + //variante jardin non dispo + //connect(jardin, &QCheckBox::toggled, this, [this](bool checked) { + // variantes[1] = checked ? 1 : 0; + //}); + connect(temple, &QCheckBox::toggled, this, [this](bool checked) { + variantes[2] = checked ? 1 : 0; + }); + connect(habitations, &QCheckBox::toggled, this, [this](bool checked) { + variantes[3] = checked ? 1 : 0; + }); + + connect(caserne, &QCheckBox::toggled, this, [this](bool checked) { + variantes[4] = checked ? 1 : 0; + }); + + + + connect(confirmBtn, &QPushButton::clicked, this, &StartMenu::onConfirmClicked); // Champ du premier joueur (min = 1) @@ -114,13 +156,16 @@ StartMenu::StartMenu(QWidget* parent) layout->addLayout(btnLayout); layout->addLayout(lineEditLayout); - // Ajoute la ligne difficulté (label + combobox) et le bouton Confirmer + // Ajoute la ligne difficulté (label + combobox), choix des variantes et le bouton Confirmer layout->addWidget(difficultyRow); + layout->addLayout(variantesLayout); layout->addWidget(confirmBtn); // Afficher la difficulté uniquement quand playerCount == 1 difficultyRow->setVisible(playerCount == 1); + + setLayout(layout); } StartMenu::~StartMenu() = default; @@ -144,7 +189,7 @@ void StartMenu::onConfirmClicked() players.push_back(lineEdit->text().toStdString()); } - emit playerSelectionConfirmed(players, dificultyLevel); + emit playerSelectionConfirmed(players, dificultyLevel, variantes); } diff --git a/src/UI/mainwindow.cpp b/src/UI/mainwindow.cpp index d71d4fa..59d3065 100644 --- a/src/UI/mainwindow.cpp +++ b/src/UI/mainwindow.cpp @@ -163,4 +163,4 @@ void MainWindow::closeEvent(QCloseEvent *event) // Handle any cleanup before closing Jeu::getInstance()->EndGame(); event->accept(); // Accept the close event -} \ No newline at end of file +} diff --git a/src/main.cpp b/src/main.cpp index 0413ffc..37db406 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,7 @@ int main(int argc, char *argv[]) Jeu *j = Jeu::getInstance(); if (argc > 1 && std::string(argv[1]) == "--no-gui") - { + { j->setQtDisplay(false); j->StartMenuC(); j->Lancer(); @@ -34,11 +34,11 @@ int main(int argc, char *argv[]) else { - QApplication a(argc, argv); + QApplication a(argc, argv); MainWindow w; - w.show(); + w.show(); - return a.exec(); + return a.exec(); } return 0; @@ -48,4 +48,4 @@ int main(int argc, char *argv[]) std::cout << e.getInfo(); return 1; } -} \ No newline at end of file +} From 0f5a9214ea2b9056c45dd4b244a6a236439fc307 Mon Sep 17 00:00:00 2001 From: clementineob Date: Sun, 21 Dec 2025 17:15:12 +0100 Subject: [PATCH 2/2] correction var + duree partie --- .qtcreator/CMakeLists.txt.user | 318 --------------------------------- include/Jeu.hpp | 22 ++- include/UI/StartMenu.hpp | 8 +- src/Cite.cpp | 9 +- src/Jeu.cpp | 65 +++++-- src/Pioche.cpp | 6 +- src/UI/StartMenu.cpp | 24 ++- src/main.cpp | 6 +- 8 files changed, 108 insertions(+), 350 deletions(-) delete mode 100644 .qtcreator/CMakeLists.txt.user diff --git a/.qtcreator/CMakeLists.txt.user b/.qtcreator/CMakeLists.txt.user deleted file mode 100644 index 55e414b..0000000 --- a/.qtcreator/CMakeLists.txt.user +++ /dev/null @@ -1,318 +0,0 @@ - - - - - - EnvironmentId - {52302327-6205-4ea2-a0c9-c36a7d74f403} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - true - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 0 - 80 - true - true - 1 - 0 - false - true - false - 2 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - false - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 4 - true - - - - true - - 0 - - - - ProjectExplorer.Project.Target.0 - - Desktop - true - Desktop Qt 6.10.1 MinGW 64-bit - Desktop Qt 6.10.1 MinGW 64-bit - qt.qt6.6101.win64_mingw_kit - 0 - 0 - 0 - - Debug - 2 - false - - -DCMAKE_GENERATOR:STRING=Ninja --DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DQT_MAINTENANCE_TOOL:FILEPATH=C:/Qt/MaintenanceTool.exe --DCMAKE_COLOR_DIAGNOSTICS:BOOL=ON --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_BUILD_TYPE:STRING=Debug - 0 - C:\Users\cleme\Desktop\Cours\GI03\LO21\projet\Akropolis.cpp\build\Desktop_Qt_6_10_1_MinGW_64_bit-Debug - - - - - all - - false - - true - Compiler - CMakeProjectManager.MakeStep - - 1 - Compiler - Compiler - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - Compiler - CMakeProjectManager.MakeStep - - 1 - Nettoyer - Nettoyer - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - 0 - 0 - - - 0 - Déploiement - Déploiement - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - - - - - - - - false - - true - Compiler - ApplicationManagerPlugin.Deploy.CMakePackageStep - - - install-package --acknowledge - true - Installer le paquet Application Manager - ApplicationManagerPlugin.Deploy.InstallPackageStep - - - - - - - - 2 - Déploiement - Déploiement - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ApplicationManagerPlugin.Deploy.Configuration - - 2 - - false - - false - - - true - true - 0 - true - - 2 - - false - -e cpu-cycles --call-graph "dwarf,4096" -F 250 - - CMakeProjectManager.CMakeRunConfiguration. - Akropolis - false - - true - true - true - %{RunConfig:Executable:Path} - - 1 - - 1 - - - 0 - Déploiement - Déploiement - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - - - - - - - - false - - true - Compiler - ApplicationManagerPlugin.Deploy.CMakePackageStep - - - install-package --acknowledge - true - Installer le paquet Application Manager - ApplicationManagerPlugin.Deploy.InstallPackageStep - - - - - - - - 2 - Déploiement - Déploiement - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ApplicationManagerPlugin.Deploy.Configuration - - 2 - - true - true - 0 - true - - 2 - - false - -e cpu-cycles --call-graph "dwarf,4096" -F 250 - - CMakeProjectManager.CMakeRunConfiguration. - Akropolis - false - - true - true - true - %{RunConfig:Executable:Path} - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - Version - 22 - - diff --git a/include/Jeu.hpp b/include/Jeu.hpp index 69db799..1c67c1e 100755 --- a/include/Jeu.hpp +++ b/include/Jeu.hpp @@ -18,8 +18,12 @@ class Pioche; enum class ModeDeJeu { Multi, Solo, - PasCommence }; +enum class Duree { + Courte, + Longue +}; + class Jeu { public: @@ -38,10 +42,10 @@ class Jeu { void StartMenuC(); void tourJoueur(Joueur* joueur); void tourIllu(Illu* illu); - + void AffFinDePartieC(); // FONCTIONS APPELLES PAR QT ET CONSOLE: - void InitialiserPartie(const std::vector& names, uint32_t difficultyLevel, std::arrayvariantes={}); - + void InitialiserPartie(const std::vector& names, uint32_t difficultyLevel, std::arrayvariantes={}, Duree d=Duree::Courte); + Joueur* gagnant(); //void setDifficultyLevel(uint32_t level) { difficultyLevel = level; } //uint32_t getDifficultyLevel() const { return difficultyLevel; } @@ -60,10 +64,10 @@ class Jeu { Tuile* choisirTuileDuChantier(Joueur* joueur); Tuile* choisirTuileDuChantier(Illu* illu); - inline ModeDeJeu getModeDeJeu() const {return mode; }; // A voir si utile, mode solo ? - //void setGameMode(ModeDeJeu mdj) { mode = mdj; } + inline ModeDeJeu getModeDeJeu() const {return mode; }; uint32_t getNbPlayers() const { return joueurs.size(); } + int getnombreTuilesPioche()const{return nombreTuilesPioche; } void setMaxPlayers(uint32_t n) { joueurs.reserve(n); maxPlayers = n; } uint32_t getMaxPlayers() const { return maxPlayers; } void addJoueur(Joueur* j) { joueurs.push_back(j); } @@ -86,7 +90,8 @@ class Jeu { Jeu(); static Jeu* instance; - ModeDeJeu mode; // A voir pendant développement mode solo, initialiser Jeu avec mode solo + ModeDeJeu mode; + Duree duree; std::vector hexs; std::vector tuilesDepart; std::vector joueurs; @@ -98,7 +103,8 @@ class Jeu { bool QtDisplay = true; int nombreTuilesChantier; int niveauDeDifficulte; - std::array variantes; + std::array variantes; + int nombreTuilesPioche; }; diff --git a/include/UI/StartMenu.hpp b/include/UI/StartMenu.hpp index 1a81fe5..01b342a 100644 --- a/include/UI/StartMenu.hpp +++ b/include/UI/StartMenu.hpp @@ -7,6 +7,9 @@ #include #include #include +#include "Jeu.hpp" + + class StartMenu : public QWidget { Q_OBJECT @@ -14,7 +17,7 @@ class StartMenu : public QWidget { StartMenu(QWidget* parent = nullptr); ~StartMenu() override; signals: - void playerSelectionConfirmed(std::vector players, uint32_t difficultyLevel, std::arrayvariantes); + void playerSelectionConfirmed(std::vector players, uint32_t difficultyLevel, std::arrayvariantes, Duree d); private slots: void onConfirmClicked(); @@ -30,8 +33,11 @@ private slots: QComboBox* dificultyComboBox; QVBoxLayout* variantesLayout; + + QHBoxLayout* longueurLayout; uint32_t playerCount; uint32_t dificultyLevel; std::array variantes; + Duree duree; std::vector playerButtons; }; diff --git a/src/Cite.cpp b/src/Cite.cpp index 453c481..a4c114c 100644 --- a/src/Cite.cpp +++ b/src/Cite.cpp @@ -688,9 +688,12 @@ uint32_t CiteJoueur::compterPoints( int niveau_difficulte, std::arrayvari cond = false; } } - if(variantes[2]==1) var = niveau; - if (cond) - points_violet += 1 * niveau * var; + if(variantes[2]==1){ + if(niveau>1){ + var = 2; + } + if (cond) points_violet += 1 * niveau * var; + } } // calcul habitation: on doit calculer les groupes d'habitations if (h->getCouleur() == Couleur::Bleu) diff --git a/src/Jeu.cpp b/src/Jeu.cpp index 90ecf19..f7ad339 100755 --- a/src/Jeu.cpp +++ b/src/Jeu.cpp @@ -64,7 +64,7 @@ void Jeu::EndGame() // Fin opérations de singleton // Constructeur créant les tuilesCité de la partie -Jeu::Jeu() : mode(ModeDeJeu::Solo), niveauDeDifficulte(0), pioche(*this) +Jeu::Jeu() : mode(ModeDeJeu::Solo), niveauDeDifficulte(0), pioche(*this), nombreTuilesPioche(61), duree(Duree::Courte) { // Définition des différentes quantités d'hexagones dans chaque catégorie @@ -215,16 +215,36 @@ void Jeu::StartMenuC() } } while (this->niveauDeDifficulte < 0 || this->niveauDeDifficulte > 2); } - - j->InitialiserPartie(names, this->niveauDeDifficulte,variantes); // difficulté 0 par défaut en mode console + std::cout<<"Voulez vous faire une partie courte ? o/n"; + std::cin>>reponse; + while(reponse != 'o' && reponse !='n'){ + std::cout<<"\nreponse invalide réesayer "; + std::cin>>reponse; + } + Duree d=Duree::Courte; + if(reponse=='n'){ + d=Duree::Longue; + } + j->InitialiserPartie(names, this->niveauDeDifficulte,variantes, d); // difficulté 0 par défaut en mode console } -void Jeu::InitialiserPartie(const std::vector &names, uint32_t difficultyLevel, std::array variantes) +void Jeu::InitialiserPartie(const std::vector &names, uint32_t difficultyLevel, std::array variantes, Duree d) { std::cout << "\n--- Initialisation de la partie ---\n"; nombreTuilesChantier = names.size() + 2; niveauDeDifficulte = difficultyLevel; - this->variantes = variantes; + this->variantes = variantes; + if(names.size()>1){ + this->mode= ModeDeJeu::Multi; + } + //gestion de la duree de la partie --> si la duree est courte on doit modifier le nombre de tuile + this->duree= d; + if(duree==Duree::Courte){ + nombreTuilesPioche = 12 * names.size() + 13; + if(mode==ModeDeJeu::Solo){ + nombreTuilesPioche = 12 * 2 +13 ; + } + } for (size_t i = 0; i < names.size(); i++) { @@ -328,13 +348,7 @@ void Jeu::Lancer() } } } - std::cout << "============== FIN DE PARTIE =====================\n"; - std::cout << "AFFICHAGE DES SCORES \n"; - for (auto &j : joueurs) - { - std::cout << j->getNom() << " : "; - std::cout << j->getCite()->compterPoints(niveauDeDifficulte, variantes) << " points" << std::endl; - } + this->AffFinDePartieC(); } int Jeu::choisirHexagoneDeReference(Tuile *t) @@ -614,3 +628,30 @@ Tuile *Jeu::choisirTuileDuChantier(Illu *illu) chantier.erase(chantier.begin()); return t; } + + + +Joueur* Jeu::gagnant(){ + Joueur* vainqueur = this->joueurs.back(); + int points_vainqueurs = this->joueurs.back()->getCite()->compterPoints(this->niveauDeDifficulte,this->variantes); + for(auto j : this->joueurs){ + int points = j->getCite()->compterPoints(this->niveauDeDifficulte,this->variantes); + if(points>=points_vainqueurs){ + vainqueur = j ; + points_vainqueurs ; + } + } + return vainqueur; +} + + +void Jeu::AffFinDePartieC(){ + std::cout << "============== FIN DE PARTIE =====================\n"; + std::cout<<"Le gagnant de la partie est le joueur "<gagnant()->getNom() ; + std::cout<<"Voici les différents scores : "<getNom() << " : "; + std::cout << j->getCite()->compterPoints(niveauDeDifficulte, variantes) << " points" << std::endl; + } +} diff --git a/src/Pioche.cpp b/src/Pioche.cpp index 192fd62..5920c70 100644 --- a/src/Pioche.cpp +++ b/src/Pioche.cpp @@ -15,10 +15,12 @@ void Pioche::init() { srand(static_cast(time(nullptr))); seedInit = true; } - + int i = 1; for (auto t : jeuRef.getTuilesCite()) { - if (t != nullptr) + if (t != nullptr && i<= jeuRef.getnombreTuilesPioche()) tuiles.push_back(t); + + i++; } } diff --git a/src/UI/StartMenu.cpp b/src/UI/StartMenu.cpp index 8946e78..da11a21 100644 --- a/src/UI/StartMenu.cpp +++ b/src/UI/StartMenu.cpp @@ -12,7 +12,7 @@ StartMenu::StartMenu(QWidget* parent) incBtn(new QPushButton("Ajouter joueurs")), confirmBtn(new GamePushButton("Confirmer")), playerCount(1), dificultyLevel(0),variantes({}), lineEditLayout(new QVBoxLayout()), countInput(new QLineEdit()), - dificultyComboBox(new QComboBox()), variantesLayout(new QVBoxLayout) + dificultyComboBox(new QComboBox()), variantesLayout(new QVBoxLayout), longueurLayout(new QHBoxLayout) { QHBoxLayout* btnLayout = new QHBoxLayout(); @@ -54,6 +54,8 @@ StartMenu::StartMenu(QWidget* parent) QCheckBox* caserne = new QCheckBox("Variante caserne"); + + variantesLayout->addWidget(var); variantesLayout->addWidget(marche); //variantesLayout->addWidget(jardin); //NON DISPO @@ -61,6 +63,13 @@ StartMenu::StartMenu(QWidget* parent) variantesLayout->addWidget(habitations); variantesLayout->addWidget(caserne); + //Selection partie longue + QLabel* longueur = new QLabel("Voulez vous faire une partie longue ? "); + QCheckBox* longue = new QCheckBox("oui"); + longueurLayout->addWidget(longueur); + longueurLayout->addWidget(longue); + + connect(dificultyComboBox, &QComboBox::currentIndexChanged, this, [this](int index) { dificultyLevel = static_cast(index); }); @@ -142,6 +151,13 @@ StartMenu::StartMenu(QWidget* parent) variantes[4] = checked ? 1 : 0; }); + connect(longue, &QCheckBox::toggled, this, [this](bool checked) { + if(checked){ + duree = Duree::Longue; + }else{ + duree = Duree::Courte; + } + }); @@ -156,11 +172,13 @@ StartMenu::StartMenu(QWidget* parent) layout->addLayout(btnLayout); layout->addLayout(lineEditLayout); - // Ajoute la ligne difficulté (label + combobox), choix des variantes et le bouton Confirmer + // Ajoute la ligne difficulté (label + combobox), choix des variantes, choix duree et le bouton Confirmer layout->addWidget(difficultyRow); layout->addLayout(variantesLayout); + layout->addLayout(longueurLayout); layout->addWidget(confirmBtn); + // Afficher la difficulté uniquement quand playerCount == 1 difficultyRow->setVisible(playerCount == 1); @@ -189,7 +207,7 @@ void StartMenu::onConfirmClicked() players.push_back(lineEdit->text().toStdString()); } - emit playerSelectionConfirmed(players, dificultyLevel, variantes); + emit playerSelectionConfirmed(players, dificultyLevel, variantes, duree); } diff --git a/src/main.cpp b/src/main.cpp index 37db406..043d702 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,10 +35,10 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; - w.show(); + MainWindow w; + w.show(); - return a.exec(); + return a.exec(); } return 0;