From dd1450e417dd25c1871df335c22ebdf2b0b309f4 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Tue, 21 Nov 2023 10:43:03 +0100 Subject: [PATCH 1/2] Ajout score dans memory --- Project/php/controller/VisitorController.php | 5 +++-- Project/php/js/memory.js | 7 ++++++- Project/php/templates/resultatsJeux.html | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 255eb4c..93ef138 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -111,8 +111,9 @@ class VisitorController UserController::home(); } - public function resultatsJeux(): void{ + public function resultatsJeux($match): void{ global $twig; - echo $twig->render('resultatsJeux.html'); + $score = Validation::filter_int($match['id']); + echo $twig->render('resultatsJeux.html', ['points' => $score]); } } \ No newline at end of file diff --git a/Project/php/js/memory.js b/Project/php/js/memory.js index f0d0923..1a9ccf3 100755 --- a/Project/php/js/memory.js +++ b/Project/php/js/memory.js @@ -4,6 +4,7 @@ document.addEventListener('DOMContentLoaded', function () { var word1; var word2; var clickEnabled = true; + var score = 25; cards.forEach(function (card) { card.addEventListener('click', function () { @@ -66,15 +67,19 @@ document.addEventListener('DOMContentLoaded', function () { (pair[0] === word1 && pair[1] === word2) || (pair[0] === word2 && pair[1] === word1) ) { + score+=10; return true; } } + if(score !== 0){ + score-=1; + } return false; } function checkGameCompletion(){ if (document.querySelectorAll('.card.found').length === cards.length) { - window.location.href = '../resultatsJeux'; // A MODIFIER POUR UN TWIG RENDER + window.location.href = '../resultatsJeux/' + score; } } }); \ No newline at end of file diff --git a/Project/php/templates/resultatsJeux.html b/Project/php/templates/resultatsJeux.html index d77d353..92b54c2 100755 --- a/Project/php/templates/resultatsJeux.html +++ b/Project/php/templates/resultatsJeux.html @@ -12,7 +12,7 @@ justify-content: center; height: 100vh; margin: 0; - background: url('../assets/img/points.png') center/cover no-repeat; + background: url('{{base}}/assets/img/points.png') center/cover no-repeat; background-color: lightslategray; } @@ -47,9 +47,9 @@
- Bravo ! Vous avez gagné 125 points !! + Votre score est de {{ points }}!
- Célébration + Célébration
From b2b45037192b0384d11618d4e68aad5f9e818d1c Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Tue, 21 Nov 2023 11:00:08 +0100 Subject: [PATCH 2/2] =?UTF-8?q?D=C3=A9tails=20visuels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/controller/VisitorController.php | 4 +++- Project/php/css/memory.css | 8 +++++++- Project/php/css/quiz.css | 2 +- Project/php/templates/memory.html | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Project/php/controller/VisitorController.php b/Project/php/controller/VisitorController.php index 93ef138..61f42a5 100755 --- a/Project/php/controller/VisitorController.php +++ b/Project/php/controller/VisitorController.php @@ -15,7 +15,8 @@ class VisitorController try{ $idVoc = Validation::filter_int($match['id'] ?? null); - $wordList = (new \gateway\TranslationGateway)->findByIdVoc($idVoc); + $wordList = (new \gateway\TranslationGateway())->findByIdVoc($idVoc); + $name = ((new \gateway\VocabularyListGateway())->findById($idVoc))->getName(); $wordShuffle = array(); shuffle($wordList); @@ -35,6 +36,7 @@ class VisitorController echo $twig->render('memory.html', [ 'wordShuffle' => $wordShuffle, 'pairs' => json_encode($pairs), + 'name' => $name ]); } diff --git a/Project/php/css/memory.css b/Project/php/css/memory.css index a68874f..3a2ce94 100755 --- a/Project/php/css/memory.css +++ b/Project/php/css/memory.css @@ -3,11 +3,17 @@ body { justify-content: center; align-items: center; height: 90vh; - background-color: #f0f0f0; + background-color: #acc2c2; margin: 2vh 15vh; overflow: hidden; } +h1{ + font-family: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Varela Round", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + text-align: center; + font-size: 5vh; +} + #memory-game { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); diff --git a/Project/php/css/quiz.css b/Project/php/css/quiz.css index cd7357e..4e97fd1 100755 --- a/Project/php/css/quiz.css +++ b/Project/php/css/quiz.css @@ -1,6 +1,6 @@ body { font-family: 'Arial', sans-serif; - background-color: #f4f4f4; + background-color: #acc2c2; margin: 0; display: flex; justify-content: center; diff --git a/Project/php/templates/memory.html b/Project/php/templates/memory.html index db1095d..7523db8 100755 --- a/Project/php/templates/memory.html +++ b/Project/php/templates/memory.html @@ -8,7 +8,7 @@
-

Memory Game : {{ nameVoc }}

+

Memory Game: {{ name }}

{% for word in wordShuffle %}