Patrick BRUGIERE 1 year ago
commit cc8dc57ef2

@ -15,7 +15,8 @@ class VisitorController
try{ try{
$idVoc = Validation::filter_int($match['id'] ?? null); $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(); $wordShuffle = array();
shuffle($wordList); shuffle($wordList);
@ -35,6 +36,7 @@ class VisitorController
echo $twig->render('memory.html', [ echo $twig->render('memory.html', [
'wordShuffle' => $wordShuffle, 'wordShuffle' => $wordShuffle,
'pairs' => json_encode($pairs), 'pairs' => json_encode($pairs),
'name' => $name
]); ]);
} }
@ -111,8 +113,9 @@ class VisitorController
UserController::home(); UserController::home();
} }
public function resultatsJeux(): void{ public function resultatsJeux($match): void{
global $twig; global $twig;
echo $twig->render('resultatsJeux.html'); $score = Validation::filter_int($match['id']);
echo $twig->render('resultatsJeux.html', ['points' => $score]);
} }
} }

@ -3,11 +3,17 @@ body {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
height: 90vh; height: 90vh;
background-color: #f0f0f0; background-color: #acc2c2;
margin: 2vh 15vh; margin: 2vh 15vh;
overflow: hidden; 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 { #memory-game {
display: grid; display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-columns: repeat(7, minmax(0, 1fr));

@ -1,6 +1,6 @@
body { body {
font-family: 'Arial', sans-serif; font-family: 'Arial', sans-serif;
background-color: #f4f4f4; background-color: #acc2c2;
margin: 0; margin: 0;
display: flex; display: flex;
justify-content: center; justify-content: center;

@ -4,6 +4,7 @@ document.addEventListener('DOMContentLoaded', function () {
var word1; var word1;
var word2; var word2;
var clickEnabled = true; var clickEnabled = true;
var score = 25;
cards.forEach(function (card) { cards.forEach(function (card) {
card.addEventListener('click', function () { card.addEventListener('click', function () {
@ -66,15 +67,19 @@ document.addEventListener('DOMContentLoaded', function () {
(pair[0] === word1 && pair[1] === word2) || (pair[0] === word1 && pair[1] === word2) ||
(pair[0] === word2 && pair[1] === word1) (pair[0] === word2 && pair[1] === word1)
) { ) {
score+=10;
return true; return true;
} }
} }
if(score !== 0){
score-=1;
}
return false; return false;
} }
function checkGameCompletion(){ function checkGameCompletion(){
if (document.querySelectorAll('.card.found').length === cards.length) { if (document.querySelectorAll('.card.found').length === cards.length) {
window.location.href = '../resultatsJeux'; // A MODIFIER POUR UN TWIG RENDER window.location.href = '../resultatsJeux/' + score;
} }
} }
}); });

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<div> <div>
<h1>Memory Game : {{ nameVoc }}</h1> <h1><u>Memory Game:</u> <i>{{ name }}</i></h1>
<div id="memory-game"> <div id="memory-game">
{% for word in wordShuffle %} {% for word in wordShuffle %}
<div class="card center-text flipped" data-word="{{ word }}"> <div class="card center-text flipped" data-word="{{ word }}">

@ -12,7 +12,7 @@
justify-content: center; justify-content: center;
height: 100vh; height: 100vh;
margin: 0; 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; background-color: lightslategray;
} }
@ -47,9 +47,9 @@
<div class="content"> <div class="content">
<div class="container"> <div class="container">
<div class="message"> <div class="message">
Bravo ! Vous avez gagné 125 points !! Votre score est de {{ points }}!
</div> </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>
</div> </div>
</body> </body>

Loading…
Cancel
Save