Session 18: Prestige Progress Bar (live visual progress toward next Stellar Essence)

This commit is contained in:
2026-08-25 10:33:27 +00:00
parent b9068e2029
commit 4e873773fe
4 changed files with 113 additions and 0 deletions
+34
View File
@@ -115,6 +115,11 @@ const PrestigeUI = {
nextEl.textContent = nextEssence;
}
// Prestige progress bar: how far total stardust is toward the next
// Stellar Essence level. essence(e) = floor(sqrt(totalStardust/1e6)),
// so tier e needs e^2*1M stardust and tier (e+1) needs (e+1)^2*1M.
this.updatePrestigeProgress();
// Update prestige button state
const prestigeBtn = document.getElementById('prestige-btn');
if (prestigeBtn) {
@@ -134,6 +139,35 @@ const PrestigeUI = {
this.updateBuyMaxPrestigeButton();
},
/**
* Update the prestige progress bar showing how close total stardust is to
* earning the next Stellar Essence. essence level e = floor(sqrt(totalStardust/1e6)),
* so tier e begins at e^2*1M and tier (e+1) begins at (e+1)^2*1M; the bar
* fills linearly across that tier's stardust range and resets to 0% exactly
* when a new essence level is reached. Read-only: mutates only DOM.
*/
updatePrestigeProgress() {
const totalStardust = Game.state.totalStardust || 0;
const e = Math.floor(Math.sqrt(totalStardust / 1e6));
const tierFloor = e * e * 1e6;
const tierCeil = (e + 1) * (e + 1) * 1e6;
const progress = Math.min(1, Math.max(0, (totalStardust - tierFloor) / (tierCeil - tierFloor)));
const fillEl = document.getElementById('prestige-progress-fill');
if (fillEl) {
const pct = Math.round(progress * 100);
fillEl.style.width = `${pct}%`;
// Only apply the pulsing glow while there is progress to show, so a
// freshly-emptied bar (e.g. right after prestige) sits still.
fillEl.classList.toggle('filling', pct > 0 && pct < 100);
}
const pctLabel = document.getElementById('prestige-progress-pct');
if (pctLabel) {
pctLabel.textContent = `${Math.round(progress * 100)}%`;
}
},
/**
* Show/hide and enable/disable the "Buy Max" prestige-upgrades button
* depending on whether at least one unowned, requirement-met prestige