diff --git a/Motus/Main.qml b/Motus/Main.qml index f86df3434a91960f7848d6dad3cb81c90ccce212..d3316c16a829a365cf3a428dc4fb3b3a9342b152 100644 --- a/Motus/Main.qml +++ b/Motus/Main.qml @@ -427,7 +427,7 @@ Window { border.width: 3 } - // Timer (positionné à droite) + // Timer MotusTimer { id: motusTimer width: 100 @@ -449,4 +449,15 @@ Window { case_focus = caseArray[0]; } } + + Text { + y: 32 + text: "⛔ Temps écoulé !" + visible: motusGame.loosebool + color: "red" + font.pixelSize: 30 + anchors.horizontalCenterOffset: 0 + anchors.horizontalCenter: parent.horizontalCenter + } + } diff --git a/Motus/motusgame.cpp b/Motus/motusgame.cpp index 59dc2015f35dba8075ca04198845f9ab08fe41f6..59d69355cd66d6f45accd43076137884ccf81c54 100644 --- a/Motus/motusgame.cpp +++ b/Motus/motusgame.cpp @@ -28,6 +28,9 @@ MotusGame::MotusGame(QObject *parent) : QObject(parent) { if (remainingTime == 0) { countdownTimer->stop(); qDebug() << "⏱️ Temps écoulé !"; + + setLoosebool(true); // ✅ Appel ici + qDebug() << "💀 Défaite enregistrée via setLoosebool(true)"; } } }); @@ -124,7 +127,7 @@ void MotusGame::setDictionnaryChoosed(const QString &value) { void MotusGame::startTimer() { qDebug() << "🔁 startTimer() appelé"; - remainingTime = 120; + remainingTime = 10; emit timerUpdated(); countdownTimer->stop(); @@ -171,12 +174,25 @@ void MotusGame::setRandomizeLetterNumber(bool value) { } +// Savoir si ça gagne ou ça perd ////////////////////////////////////////////////////////////////////////////////////////// +bool MotusGame::getLoosebool() const { + return loose; +} +bool MotusGame::getWinbool() const { + return loose; +} +void MotusGame::setLoosebool(bool value){ + loose=value; + emit looseChanged(); +} - - +void MotusGame::setWinbool(bool value){ + win=value; + emit winChanged(); +} diff --git a/Motus/motusgame.h b/Motus/motusgame.h index ee58aed6b8665ac89536c36cc556840b87008964..676660ed2b3b93e2db55db6bc3dbee182cdca5e4 100644 --- a/Motus/motusgame.h +++ b/Motus/motusgame.h @@ -22,6 +22,11 @@ class MotusGame : public QObject { Q_PROPERTY(bool randomizeLetterNumber READ getRandomizeLetterNumber WRITE setRandomizeLetterNumber NOTIFY randomizeLetterNumberChanged) + Q_PROPERTY(bool loosebool READ getLoosebool WRITE setLoosebool NOTIFY looseChanged) + + Q_PROPERTY(bool winbool READ getWinbool WRITE setWinbool NOTIFY winChanged) + + public: explicit MotusGame(QObject *parent = nullptr); @@ -39,6 +44,11 @@ public: bool getRandomizeLetterNumber() const; void setRandomizeLetterNumber(bool value); + bool getLoosebool() const; + Q_INVOKABLE void setLoosebool(bool value); + bool getWinbool() const; + Q_INVOKABLE void setWinbool(bool value); + Q_INVOKABLE bool existWord(const QString &word); @@ -63,6 +73,9 @@ private: int remainingTime = 120; // chrono en secondes + bool loose = false; + bool win = false; + void loadWords(); signals: @@ -70,6 +83,8 @@ signals: void timerUpdated(); void letterNumberChanged(); void randomizeLetterNumberChanged(); + void looseChanged(); + void winChanged(); };