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.
This commit is contained in:
Joel Brock
2026-06-20 11:50:33 -07:00
parent ac69e456d9
commit 3a4c2579a5
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -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);
+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE_NAME = 'tortugotchi-v13';
const CACHE_NAME = 'tortugotchi-v14';
const ASSETS = [
'./',
'./index.html',