Add hint cooldown and raise player limit to 15

- Lock hint button for 10s per riddle with live countdown display
- Clear hint timer when player finishes their race
- Raise max players from 8 to 15 with 15 distinct player colors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-18 14:12:20 +00:00
parent 973fd9ba9b
commit 35bc70d065
3 changed files with 29 additions and 3 deletions

View File

@@ -11,6 +11,7 @@ let myRoomId = null;
let amHost = false;
let myFinished = false;
let carEmojiMap = {}; // playerId → car emoji
let hintTimer = null; // countdown interval for hint button
// ── Screen helpers ─────────────────────
const screens = {
@@ -225,6 +226,28 @@ function showRiddle(riddle, num, total) {
hintBox.style.display = 'none';
hintText.textContent = '';
answerInput.focus();
startHintCountdown();
}
function startHintCountdown() {
clearInterval(hintTimer);
hintBox.style.display = 'none';
hintBtn.disabled = true;
let remaining = 10;
hintBtn.textContent = `💡 Hint (${remaining}s)`;
hintTimer = setInterval(() => {
remaining--;
if (remaining <= 0) {
clearInterval(hintTimer);
hintTimer = null;
hintBtn.disabled = false;
hintBtn.textContent = '💡 Hint';
} else {
hintBtn.textContent = `💡 Hint (${remaining}s)`;
}
}, 1000);
}
function setFeedback(msg, isCorrect) {
@@ -359,6 +382,8 @@ socket.on('answerResult', ({ correct, finished, finishPosition, riddle, riddleNu
if (finished) {
myFinished = true;
clearInterval(hintTimer);
hintTimer = null;
progressFill.style.width = '100%';
riddlePanel.style.display = 'none';
finishedBanner.style.display = 'flex';

View File

@@ -43,7 +43,7 @@
<div id="error-msg" class="error-msg"></div>
</div>
<p class="home-footer">Up to 8 players &bull; Answer 10 riddles to cross the finish line</p>
<p class="home-footer">Up to 15 players &bull; Answer 10 riddles to cross the finish line</p>
</div>
</div>