diff --git a/tools/2048/index.html b/tools/2048/index.html index 838107c..13d7a4a 100644 --- a/tools/2048/index.html +++ b/tools/2048/index.html @@ -1,5 +1,5 @@ - + @@ -14,6 +14,7 @@ align-items: center; /*height: 100vh;*/ background-color: #faf8ef; + margin:0px; } #score { font-size: 24px; @@ -36,6 +37,23 @@ align-items: center; border-radius: 5px; } + #leaderboard { + justify-content: right; + } + .dashboard-cards { + background-color: #f9f9f9; + border-radius: 10px; + padding: 20px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + text-align: center; + margin-bottom: 20px; + } + .dashboard { + display: flex; + flex-direction: row; + align-items: center; + gap: 15px; + } .tile[data-value="2"] { background-color: #eee4da; color: #776e65; } .tile[data-value="4"] { background-color: #ede0c8; color: #776e65; } .tile[data-value="8"] { background-color: #f2b179; color: #f9f6f2; } @@ -65,6 +83,11 @@ + + + + + @@ -100,14 +123,16 @@ + +
Score: 0
+
+
+

Leaderboard

+
+
-
Score: 0
-
- - - - - -
-

Leaderboard

-
diff --git a/tools/assets/js/2048.js b/tools/assets/js/2048.js index ff30ed4..62fcb21 100644 --- a/tools/assets/js/2048.js +++ b/tools/assets/js/2048.js @@ -9,6 +9,7 @@ addRandomTile(); addRandomTile(); updateBoard(); + getLeaderboard(); } function updateScore() { @@ -136,9 +137,7 @@ break; } updateBoard(); - if (checkGameOver()) { - initBoard(); - } + checkGameOver(); }); /*LEADERBOARD*/ @@ -157,6 +156,9 @@ async function getLeaderboard() { const leaderboard = document.getElementById('leaderboard'); leaderboard.innerHTML = ''; // Clear current leaderboard + const title = document.createElement('h2'); + title.textContent = "Leaderboard"; + leaderboard.appendChild(title); try { const querySnapshot = await db.collection("leaderboard") @@ -164,11 +166,14 @@ .limit(10) // Limite à 10 les scores affichés .get(); + cnt = 1; querySnapshot.forEach((doc) => { const data = doc.data(); const entry = document.createElement('div'); - entry.textContent = `${data.username}: ${data.score}`; + entry.textContent = `${cnt} | ${data.username} | highest score: ${data.score}`; + cnt += 1; leaderboard.appendChild(entry); + console.log(entry.textContent); }); } catch (e) { console.error("Error getting documents: ", e); @@ -179,7 +184,6 @@ if (playerName) { addScoreToLeaderboard(playerName, score); } - getLeaderboard(); // Met à jour le leaderboard après avoir ajouté un nouveau score initBoard(); // Redémarre le jeu } diff --git a/tools/maze/index.html b/tools/maze/index.html index d65d927..c1ee223 100644 --- a/tools/maze/index.html +++ b/tools/maze/index.html @@ -97,7 +97,8 @@ -