From a5c49941ea7b3563561d06f7d6bfd21d61e21fcf Mon Sep 17 00:00:00 2001
From: ppouchet <pierre.pouchet@etu.ec-lyon.fr>
Date: Mon, 31 Mar 2025 11:35:23 +0200
Subject: [PATCH] =?UTF-8?q?Diff=C3=A9renciation=20loose=20par=20nombre=20d?=
 =?UTF-8?q?'essais=20ou=20temps=20=C3=A9coul=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Motus/Main.qml      | 15 ++++++++++++---
 Motus/motusgame.cpp | 22 ++++++++++++++++------
 Motus/motusgame.h   | 16 +++++++++++-----
 3 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/Motus/Main.qml b/Motus/Main.qml
index 802113c..dfcb131 100644
--- a/Motus/Main.qml
+++ b/Motus/Main.qml
@@ -43,7 +43,7 @@ Window {
 
         // Gestion des touches du clavier physique
         Keys.onPressed: function(event) {
-            if (mot !== "" && !motusGame.loose && !motusGame.win) {
+            if (mot !== "" && !motusGame.loosetry && !motusGame.win && !motusGame.loosetime) {
                 // Saisie d'une lettre (de A à Z)
                 if (/^[a-zA-Z]$/.test(event.text)) {
                     if (indice_case < nb_lettres) {
@@ -493,8 +493,17 @@ Window {
 
     Text {
         y: 32
-        text: "⛔ Temps écoulé !"
-        visible: motusGame.loose
+        text: "Temps écoulé ! Mot : "+mot
+        visible: motusGame.loosetime
+        color: "red"
+        font.pixelSize: 30
+        anchors.horizontalCenter: parent.horizontalCenter
+    }
+
+    Text {
+        y: 32
+        text: "Nombre d'essais maximum atteint ! Mot : "+mot
+        visible: motusGame.loosetry
         color: "red"
         font.pixelSize: 30
         anchors.horizontalCenter: parent.horizontalCenter
diff --git a/Motus/motusgame.cpp b/Motus/motusgame.cpp
index 007fe63..6f9ba32 100644
--- a/Motus/motusgame.cpp
+++ b/Motus/motusgame.cpp
@@ -29,7 +29,7 @@ MotusGame::MotusGame(QObject *parent) : QObject(parent) {
                 countdownTimer->stop();
                 qDebug() << "⏱️ Temps écoulé !";
 
-                setLoosebool(true);  // ✅ Appel ici
+                setLoosetimebool(true);  // ✅ Appel ici
                 qDebug() << "💀 Défaite enregistrée via setLoosebool(true)";
             }
         }
@@ -180,18 +180,28 @@ void MotusGame::setRandomizeLetterNumber(bool value) {
 
 // Savoir si ça gagne ou ça perd //////////////////////////////////////////////////////////////////////////////////////////
 
-bool MotusGame::getLoosebool() const {
-    return loose;
+bool MotusGame::getLoosetrybool() const {
+    return loosetry;
 }
 
 bool MotusGame::getWinbool() const {
     return win;
 }
 
-void MotusGame::setLoosebool(bool value){
-    loose=value;
+bool MotusGame::getLoosetimebool() const {
+    return loosetime;
+}
+
+void MotusGame::setLoosetimebool(bool value){
+    loosetime=value;
+    this->stopTimer();
+    emit loosetimeChanged();
+}
+
+void MotusGame::setLoosetrybool(bool value){
+    loosetry=value;
     this->stopTimer();
-    emit looseChanged();
+    emit loosetryChanged();
 }
 
 void MotusGame::setWinbool(bool value){
diff --git a/Motus/motusgame.h b/Motus/motusgame.h
index c1c4457..8ed3743 100644
--- a/Motus/motusgame.h
+++ b/Motus/motusgame.h
@@ -22,7 +22,9 @@ class MotusGame : public QObject {
 
     Q_PROPERTY(bool randomizeLetterNumber READ getRandomizeLetterNumber WRITE setRandomizeLetterNumber NOTIFY randomizeLetterNumberChanged)
 
-    Q_PROPERTY(bool loose READ getLoosebool WRITE setLoosebool NOTIFY looseChanged)
+    Q_PROPERTY(bool loosetry READ getLoosetrybool WRITE setLoosetrybool NOTIFY loosetryChanged)
+
+    Q_PROPERTY(bool loosetime READ getLoosetimebool WRITE setLoosetimebool NOTIFY loosetimeChanged)
 
     Q_PROPERTY(bool win READ getWinbool WRITE setWinbool NOTIFY winChanged)
 
@@ -45,8 +47,10 @@ public:
     bool getRandomizeLetterNumber() const;
     void setRandomizeLetterNumber(bool value);
 
-    bool getLoosebool() const;
-    Q_INVOKABLE void setLoosebool(bool value);
+    bool getLoosetrybool() const;
+    Q_INVOKABLE void setLoosetrybool(bool value);
+    bool getLoosetimebool() const;
+    Q_INVOKABLE void setLoosetimebool(bool value);
     bool getWinbool() const;
     Q_INVOKABLE void setWinbool(bool value);
 
@@ -76,7 +80,8 @@ private:
 
     int remainingTime = 120; // chrono en secondes
 
-    bool loose = false;
+    bool loosetry = false;
+    bool loosetime = false;
     bool win = false;
 
     void loadWords();
@@ -86,7 +91,8 @@ signals:
     void timerUpdated();
     void letterNumberChanged();
     void randomizeLetterNumberChanged();
-    void looseChanged();
+    void loosetryChanged();
+    void loosetimeChanged();
     void winChanged();
 
 
-- 
GitLab