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:
@@ -61,6 +61,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
let beachingProgress = 0; // 0 to 100
|
let beachingProgress = 0; // 0 to 100
|
||||||
let beachingInterval = null;
|
let beachingInterval = null;
|
||||||
let beachingTouristsInterval = 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
|
// 2. DOM ELEMENTS
|
||||||
@@ -571,9 +575,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
saveProgress();
|
saveProgress();
|
||||||
|
|
||||||
// Beaching happens on a regular cycle for healthy adults — roughly
|
// Beaching is an occasional event for healthy adults. A cooldown plus a
|
||||||
// every few minutes of active play.
|
// low per-tick chance keeps it to roughly once every several minutes
|
||||||
if (turtleAge > 7 && stats.health > 50 && Math.random() < 0.18) {
|
// 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);
|
changeState(STATES.BEACHING);
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|||||||
Reference in New Issue
Block a user