From f81268e5151100a520aabc32a79b9ad9caccbac9 Mon Sep 17 00:00:00 2001 From: Ulysse Durand <ulysse.durand@ens-lyon.fr> Date: Fri, 11 Apr 2025 22:10:52 +0200 Subject: [PATCH] =?UTF-8?q?=C3=87a=20bug=20moins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- motus/CMakeLists.txt | 2 +- motus/Grille.qml | 18 ------------------ motus/brain.cpp | 2 +- motus/jeu.cpp | 24 +++++++----------------- motus/jeu.h | 2 ++ motus/ligne.cpp | 1 - 6 files changed, 11 insertions(+), 38 deletions(-) delete mode 100644 motus/Grille.qml diff --git a/motus/CMakeLists.txt b/motus/CMakeLists.txt index bd2571f..2aa1556 100644 --- a/motus/CMakeLists.txt +++ b/motus/CMakeLists.txt @@ -37,7 +37,7 @@ qt_add_qml_module(appmotus SOURCES jeu.h jeu.cpp SOURCES QML_FILES Case.qml - QML_FILES Grille.qml + QML_FILES SOURCES lettermodel.h lettermodel.cpp ) diff --git a/motus/Grille.qml b/motus/Grille.qml deleted file mode 100644 index bf3708c..0000000 --- a/motus/Grille.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick -import QtQuick.Controls - -Grid { - id: grille - rows: jeu.grilleManager.rows // Get the number of rows dynamically - columns: jeu.grilleManager.columns // Get the number of columns dynamically - spacing: 5 - - // Use a Repeater to populate the grid with cases - Repeater { - model: jeu.grilleManager.cases - delegate: Case { - letter: modelData.letter - etat: modelData.etat - } - } -} diff --git a/motus/brain.cpp b/motus/brain.cpp index 0ebc8d9..23d5cdb 100644 --- a/motus/brain.cpp +++ b/motus/brain.cpp @@ -94,7 +94,7 @@ void Brain::trouveMot() { cout << "Mot de taille : " << mTailleMot << " dans " << dico << endl; while (std::getline(file, line)) { if (line.length() == mTailleMot + 1) { - listeMots.push_back(line.substr(0, 8)); + listeMots.push_back(line.substr(0, mTailleMot)); } } diff --git a/motus/jeu.cpp b/motus/jeu.cpp index 4b1444e..96a47bd 100644 --- a/motus/jeu.cpp +++ b/motus/jeu.cpp @@ -5,34 +5,26 @@ Jeu::Jeu(QObject* rootObject, QObject *parent) : QObject(parent), rootObject(rootObject) { brain = new Brain("./"); -} - -// void Jeu::setMot(const QString& mot) { -// this->mot = mot; -// grilleManager.createGrid(mot.length(), 1); // Utilise la longueur du mot pour la grille -// emit motChanged(); -// } + width = 8; + height = 5; +} QString Jeu::getMotAffiche() { return mot; } void Jeu::onClavierClick(QString lettre) { - - - if (!m_letterModel) return; - if (currentIndex < 40) { // on évite de dépasser la grille + if (currentIndex < width*height) { m_letterModel->setLetter(currentIndex, lettre); currentIndex++; } - brain->entreLettre(lettre.toStdString()[0]); - for (int index = 0; index < 40; index ++) { + for (int index = 0; index < width*height; index ++) { m_letterModel->setLetter(index, QString::fromLatin1(&brain->getGrid()[index], 1)); } } @@ -46,12 +38,10 @@ void Jeu::initGame() { void Jeu::startGame() { brain->setFichierDico("words_alpha.txt"); - brain->setNombreEssais(5); - brain->setTailleMots(8); + brain->setNombreEssais(height); + brain->setTailleMots(width); brain->initGame(); - - // grilleManager.createGrid(6, 5); // à synchroniser avec les paramètres du brain } void Jeu::setLetterModel(LetterModel* model) { diff --git a/motus/jeu.h b/motus/jeu.h index 6d9c03d..056333a 100644 --- a/motus/jeu.h +++ b/motus/jeu.h @@ -33,6 +33,8 @@ private: QQuickItem* gameWindow; // Pointer to the QQuickItem of the GameWindow LetterModel* m_letterModel = nullptr; // Modèle QML int currentIndex = 0; // Pour suivre où on écrit + int width; + int height; }; #endif // JEU_H diff --git a/motus/ligne.cpp b/motus/ligne.cpp index 51c01db..8373c23 100644 --- a/motus/ligne.cpp +++ b/motus/ligne.cpp @@ -4,7 +4,6 @@ #include "iostream" #include <cctype> using namespace std; -#include <QString> Ligne::Ligne(string bonmot) : bonmot(bonmot), positionCurseur(0) {} -- GitLab