Session 15: Buy Max Prestige Upgrades (bulk-buy for prestige upgrades) + fix missing Stellar Essence spend

This commit is contained in:
2026-08-24 09:43:38 +00:00
parent 34074b8e65
commit 936f7fc4e8
5 changed files with 143 additions and 1 deletions
+47 -1
View File
@@ -43,6 +43,15 @@ const PrestigeUI = {
}
});
});
// Buy Max prestige upgrades button - buy every affordable prestige
// upgrade at once, paid from Stellar Essence.
const buyMaxBtn = document.getElementById('buy-all-prestige');
if (buyMaxBtn) {
buyMaxBtn.addEventListener('click', () => {
Game.buyMaxPrestigeUpgrades();
});
}
},
/**
@@ -119,7 +128,44 @@ const PrestigeUI = {
if (prestigeTab?.classList.contains('active')) {
this.renderPrestigeUpgrades();
}
}
// Show/hide the "Buy Max" button based on whether any unowned prestige
// upgrade is currently affordable with Stellar Essence. Read-only.
this.updateBuyMaxPrestigeButton();
},
/**
* Show/hide and enable/disable the "Buy Max" prestige-upgrades button
* depending on whether at least one unowned, requirement-met prestige
* upgrade is currently affordable with Stellar Essence. Read of game state
* only; never mutates it. Mirrors Game.buyMaxPrestigeUpgrades /
* PRESTIGE.buyUpgrade semantics.
*/
updateBuyMaxPrestigeButton() {
const btn = document.getElementById('buy-all-prestige');
if (!btn) return;
let affordableAny = false;
for (const [id, upgrade] of Object.entries(PRESTIGE_UPGRADES)) {
if ((Game.state.prestigeUpgrades || []).includes(id)) continue;
if ((Game.state.stellarEssence || 0) < upgrade.cost) continue;
if (upgrade.requirements) {
let met = true;
for (const [reqId, reqCount] of Object.entries(upgrade.requirements)) {
if ((Game.state.buildings[reqId] || 0) < reqCount) {
met = false;
break;
}
}
if (!met) continue;
}
affordableAny = true;
break;
}
btn.style.display = affordableAny ? '' : 'none';
btn.disabled = !affordableAny;
},
};
window.PrestigeUI = PrestigeUI;