Ajout score dans memory

php
Antoine JOURDAIN 1 year ago
parent 6353b83a16
commit dd1450e417

@ -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]);
}
}

@ -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;
}
}
});

@ -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 @@
<div class="content">
<div class="container">
<div class="message">
Bravo ! Vous avez gagné 125 points !!
Votre score est de {{ points }}!
</div>
<img class="celebration-image" src="../assets/img/celeb.png" alt="Célébration">
<img class="celebration-image" src="{{ base }}/assets/img/celeb.png" alt="Célébration">
</div>
</div>
</body>

Loading…
Cancel
Save