diff --git a/Motus/Main.qml b/Motus/Main.qml index 2ca0d57c6df4883296217caaded54f602d96b916..f86df3434a91960f7848d6dad3cb81c90ccce212 100644 --- a/Motus/Main.qml +++ b/Motus/Main.qml @@ -59,13 +59,14 @@ Window { console.log(indice_case); if (indice_case === nb_lettres) { var mot_entre = ""; - for (var i = 0; i<nb_lettres; i++){ - mot_entre += caseArray[current_essai * nb_lettres + indice_case]._textText; + for (var i = 0; i < nb_lettres; i++){ + console.log(caseArray[current_essai * nb_lettres + i]._textText); + mot_entre += caseArray[current_essai * nb_lettres + i]._textText; } - + console.log("Mot entré :", mot_entre.toUpperCase()); if (motusGame.existWord(mot_entre.toUpperCase())){ // Vérification de la proposition sur la ligne actuelle - for (i = 0; i < nb_lettres; i++) { + for (var i = 0; i < nb_lettres; i++) { var case_verif = caseArray[current_essai * nb_lettres + i]; var lettre_verif = case_verif._textText; if (lettre_verif === mot_split[i].toUpperCase()) { @@ -81,7 +82,7 @@ Window { } } } - // Après vérification, passage à la ligne suivante si possible + // Passage à la ligne suivante si possible if (current_essai < nb_essais - 1) { current_essai++; indice_case = 0; @@ -89,16 +90,15 @@ Window { // Fin de partie : vous pouvez désactiver l'interface ou afficher un message mot = ""; } - } - else{ + } else { + // Le mot n'existe pas dans le dictionnaire : coloration en rouge puis réinitialisation for (i = 0; i < nb_lettres; i++) { case_verif = caseArray[current_essai * nb_lettres + i]; case_verif.rectangleColor = "#cf1b2a"; case_verif.rectangleBordercolor = "#cf1b2a"; - revertTimer.start(); } + revertTimer.start(); } - event.accepted = true; } } diff --git a/Motus/motusgame.cpp b/Motus/motusgame.cpp index 864ef8e87a0d3021d51e3f221fb9c7170b178cd5..59dc2015f35dba8075ca04198845f9ab08fe41f6 100644 --- a/Motus/motusgame.cpp +++ b/Motus/motusgame.cpp @@ -72,10 +72,11 @@ void MotusGame::loadWords() { bool MotusGame::existWord(const QString &word) { int n = word.size(); bool exists = false; - + qDebug() << "Recherche du mot :" << word; // Supposons que wordsByLength est un QMap<int, QStringList> const QStringList &list = wordsByLength[n]; for (int i = 0; i < list.size(); i++) { + qDebug() << list[i].toUpper(); if (list[i].toUpper() == word) { exists = true; break; // On arrête la recherche dès qu'on trouve le mot