From 3a4c2579a50b77b29714b9cf0f69423b488a9bb8 Mon Sep 17 00:00:00 2001 From: Joel Brock Date: Sat, 20 Jun 2026 11:50:33 -0700 Subject: [PATCH] Reduce beaching event frequency Lower the per-tick beaching chance from 18% to 4% and add a 5-minute cooldown so beaching stays an occasional event instead of interrupting ocean play every minute. Bump service worker cache to v14. --- app.js | 13 ++++++++++--- sw.js | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app.js b/app.js index 03fbcfc..c6bd745 100644 --- a/app.js +++ b/app.js @@ -61,6 +61,10 @@ document.addEventListener('DOMContentLoaded', () => { let beachingProgress = 0; // 0 to 100 let beachingInterval = null; let beachingTouristsInterval = null; + // Earliest time (ms) the next beaching event may trigger. Keeps beaching to + // an occasional event rather than something that interrupts every minute. + const BEACHING_COOLDOWN_MS = 5 * 60 * 1000; + let nextBeachingAllowedAt = 0; // ========================================== // 2. DOM ELEMENTS @@ -571,9 +575,12 @@ document.addEventListener('DOMContentLoaded', () => { saveProgress(); - // Beaching happens on a regular cycle for healthy adults — roughly - // every few minutes of active play. - if (turtleAge > 7 && stats.health > 50 && Math.random() < 0.18) { + // Beaching is an occasional event for healthy adults. A cooldown plus a + // low per-tick chance keeps it to roughly once every several minutes + // rather than interrupting play every minute. + if (turtleAge > 7 && stats.health > 50 && + Date.now() >= nextBeachingAllowedAt && Math.random() < 0.04) { + nextBeachingAllowedAt = Date.now() + BEACHING_COOLDOWN_MS; changeState(STATES.BEACHING); } }, 10000); diff --git a/sw.js b/sw.js index d9f2b25..92079d5 100644 --- a/sw.js +++ b/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'tortugotchi-v13'; +const CACHE_NAME = 'tortugotchi-v14'; const ASSETS = [ './', './index.html',