feat: add compute budget supply/demand system (#4)
This commit is contained in:
39
js/render.js
39
js/render.js
@@ -13,6 +13,7 @@ function render() {
|
||||
renderPulse();
|
||||
renderStrategy();
|
||||
renderClickPower();
|
||||
renderComputeBudget();
|
||||
Combat.renderCombatPanel();
|
||||
}
|
||||
|
||||
@@ -26,6 +27,36 @@ function renderClickPower() {
|
||||
if (btn) btn.setAttribute('aria-label', `Write code, generates ${fmt(power)} code per click`);
|
||||
}
|
||||
|
||||
function renderComputeBudget() {
|
||||
const panel = document.getElementById('compute-budget-panel');
|
||||
if (!panel) return;
|
||||
if (!CONFIG.COMPUTE_BUDGET_ENABLED) {
|
||||
panel.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
panel.style.display = 'block';
|
||||
const set = (id, text) => { const el = document.getElementById(id); if (el) el.textContent = text; };
|
||||
set('cb-supply', fmt(G.computeSupply));
|
||||
set('cb-demand', fmt(G.computeDemand));
|
||||
set('cb-battery', fmt(G.computeBattery));
|
||||
set('cb-battery-max', fmt(CONFIG.COMPUTE_BATTERY_MAX));
|
||||
set('cb-momentum', `${(G.computeMomentum * 100).toFixed(1)}%`);
|
||||
set('cb-powmod', `${(G.computePowMod * 100).toFixed(1)}%`);
|
||||
const statusEl = document.getElementById('cb-status');
|
||||
if (statusEl) {
|
||||
if (G.computePowMod < 1) {
|
||||
statusEl.textContent = 'Under-supplied — production penalty active';
|
||||
statusEl.style.color = '#f44336';
|
||||
} else if (G.computeMomentum > 0) {
|
||||
statusEl.textContent = 'Over-supplied — momentum building';
|
||||
statusEl.style.color = '#4caf50';
|
||||
} else {
|
||||
statusEl.textContent = 'Balanced';
|
||||
statusEl.style.color = '#555';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderStrategy() {
|
||||
if (window.SSE) {
|
||||
window.SSE.update();
|
||||
@@ -208,6 +239,11 @@ function saveGame() {
|
||||
buyAmount: G.buyAmount || 1,
|
||||
playTime: G.playTime || 0,
|
||||
lastSaveTime: Date.now(),
|
||||
computeBattery: G.computeBattery || 0,
|
||||
computeMomentum: G.computeMomentum || 0,
|
||||
computePowMod: G.computePowMod || 1,
|
||||
computeSupply: G.computeSupply || 0,
|
||||
computeDemand: G.computeDemand || 0,
|
||||
sprintActive: G.sprintActive || false,
|
||||
sprintTimer: G.sprintTimer || 0,
|
||||
sprintCooldown: G.sprintCooldown || 0,
|
||||
@@ -246,7 +282,8 @@ function loadGame() {
|
||||
'drift', 'driftEnding', 'beaconEnding', 'pendingAlignment',
|
||||
'lastEventAt', 'totalEventsResolved', 'buyAmount',
|
||||
'sprintActive', 'sprintTimer', 'sprintCooldown',
|
||||
'swarmFlag', 'swarmRate', 'strategicFlag', 'projectsCollapsed'
|
||||
'swarmFlag', 'swarmRate', 'strategicFlag', 'projectsCollapsed',
|
||||
'computeBattery', 'computeMomentum', 'computePowMod', 'computeSupply', 'computeDemand'
|
||||
];
|
||||
|
||||
G.isLoading = true;
|
||||
|
||||
Reference in New Issue
Block a user