made changes to timer

This commit is contained in:
Michael Andrew Maurakis 2025-01-20 02:30:36 -06:00
parent bbf662fb6d
commit b8053dc9e8

View file

@ -215,7 +215,9 @@
} }
let lastFumbleTime = 0; let lastFumbleTime = 0;
const cooldownPeriod = 5000; // 5 seconds cooldown const cooldownPeriod = 2000; // Reduce to 2 seconds cooldown
const warningThreshold = 3; // Number of quick fumbles before warning
let quickFumbleCount = 0;
let cooldownTimer = null; let cooldownTimer = null;
const fumble = () => { const fumble = () => {
@ -223,31 +225,36 @@
const timeSinceLastFumble = currentTime - lastFumbleTime; const timeSinceLastFumble = currentTime - lastFumbleTime;
if (timeSinceLastFumble < cooldownPeriod) { if (timeSinceLastFumble < cooldownPeriod) {
// Show warning modal quickFumbleCount++;
const warningModal = document.getElementById("warningModal"); if (quickFumbleCount >= warningThreshold) {
const cooldownSeconds = document.getElementById("cooldownSeconds"); // Show warning modal
const closeBtn = document.getElementById("warningCloseBtn"); const warningModal = document.getElementById('warningModal');
warningModal.classList.add("show"); const cooldownSeconds = document.getElementById('cooldownSeconds');
closeBtn.disabled = true; const closeBtn = document.getElementById('warningCloseBtn');
warningModal.classList.add('show');
closeBtn.disabled = true;
// Update countdown timer // Update countdown timer
let remainingTime = 5; // 5 second countdown for closing let remainingTime = 3; // Reduce to 3 second countdown for closing
cooldownSeconds.textContent = remainingTime; cooldownSeconds.textContent = remainingTime;
if (cooldownTimer) clearInterval(cooldownTimer); if (cooldownTimer) clearInterval(cooldownTimer);
cooldownTimer = setInterval(() => { cooldownTimer = setInterval(() => {
remainingTime--; remainingTime--;
if (remainingTime <= 0) { if (remainingTime <= 0) {
cooldownSeconds.textContent = "0"; cooldownSeconds.textContent = '0';
closeBtn.disabled = false; closeBtn.disabled = false;
clearInterval(cooldownTimer); clearInterval(cooldownTimer);
} else { quickFumbleCount = 0; // Reset counter after warning
cooldownSeconds.textContent = remainingTime; } else {
cooldownSeconds.textContent = remainingTime;
}
}, 1000);
return;
} }
}, 1000); } else {
quickFumbleCount = 0; // Reset counter if enough time has passed
return;
} }
lastFumbleTime = currentTime; lastFumbleTime = currentTime;