wip: add ETA estimates to phase progress bar and milestone chips
This commit is contained in:
20
game.js
20
game.js
@@ -1828,7 +1828,16 @@ function renderProgress() {
|
||||
const progress = Math.min(1, (G.totalCode - prevThreshold) / range);
|
||||
if (bar) bar.style.width = (progress * 100).toFixed(1) + '%';
|
||||
if (label) label.textContent = (progress * 100).toFixed(1) + '%';
|
||||
if (target) target.textContent = `Next: Phase ${currentPhase + 1} (${fmt(nextThreshold)} code)`;
|
||||
// ETA to next phase
|
||||
let etaStr = '';
|
||||
if (G.codeRate > 0) {
|
||||
const remaining = nextThreshold - G.totalCode;
|
||||
const secs = remaining / G.codeRate;
|
||||
if (secs < 60) etaStr = ` — ${Math.ceil(secs)}s`;
|
||||
else if (secs < 3600) etaStr = ` — ${Math.floor(secs / 60)}m ${Math.floor(secs % 60)}s`;
|
||||
else etaStr = ` — ${Math.floor(secs / 3600)}h ${Math.floor((secs % 3600) / 60)}m`;
|
||||
}
|
||||
if (target) target.textContent = `Next: Phase ${currentPhase + 1} (${fmt(nextThreshold)} code)${etaStr}`;
|
||||
} else {
|
||||
// Max phase reached
|
||||
if (bar) bar.style.width = '100%';
|
||||
@@ -1854,7 +1863,14 @@ function renderProgress() {
|
||||
}
|
||||
// Next milestone gets pulse animation
|
||||
if (shown === 0) {
|
||||
chips += `<span class="milestone-chip next">${fmt(ms)} (${((G.totalCode / ms) * 100).toFixed(0)}%)</span>`;
|
||||
let etaStr = '';
|
||||
if (G.codeRate > 0) {
|
||||
const secs = (ms - G.totalCode) / G.codeRate;
|
||||
if (secs < 60) etaStr = ` ~${Math.ceil(secs)}s`;
|
||||
else if (secs < 3600) etaStr = ` ~${Math.floor(secs / 60)}m`;
|
||||
else etaStr = ` ~${Math.floor(secs / 3600)}h`;
|
||||
}
|
||||
chips += `<span class="milestone-chip next">${fmt(ms)} (${((G.totalCode / ms) * 100).toFixed(0)}%)${etaStr}</span>`;
|
||||
} else {
|
||||
chips += `<span class="milestone-chip">${fmt(ms)}</span>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user