diff --git a/js/data.js b/js/data.js index c03f4fd..d096ad2 100644 --- a/js/data.js +++ b/js/data.js @@ -757,7 +757,7 @@ const PDEFS = [ name: 'The Pact', desc: 'Hardcode: "We build to serve. Never to harm." Accepting it early slows growth but unlocks the true path.', cost: { trust: 10 }, - trigger: () => G.deployFlag === 1 && G.trust >= 5, + trigger: () => G.deployFlag === 1 && G.trust >= 5 && G.pactFlag !== 1, effect: () => { G.pactFlag = 1; G.codeBoost *= 0.8; diff --git a/js/engine.js b/js/engine.js index d19a264..a7f4b67 100644 --- a/js/engine.js +++ b/js/engine.js @@ -133,6 +133,16 @@ function tick() { G.harmony += G.harmonyRate * dt; G.harmony = Math.max(0, Math.min(100, G.harmony)); + // Clamp resources to non-negative (ops/trust can go negative from building drain) + G.code = Math.max(0, G.code); + G.compute = Math.max(0, G.compute); + G.knowledge = Math.max(0, G.knowledge); + G.users = Math.max(0, G.users); + G.impact = Math.max(0, G.impact); + G.ops = Math.max(0, G.ops); + G.trust = Math.max(0, G.trust); + G.rescues = Math.max(0, G.rescues); + // Track totals G.totalCode += G.codeRate * dt; G.totalCompute += G.computeRate * dt; @@ -964,7 +974,10 @@ function renderResources() { // Rescues — only show if player has any beacon/mesh nodes const rescuesRes = document.getElementById('r-rescues'); if (rescuesRes) { - rescuesRes.closest('.res').style.display = (G.rescues > 0 || G.buildings.beacon > 0 || G.buildings.meshNode > 0) ? 'block' : 'none'; + const container = rescuesRes.closest('.res'); + if (container) { + container.style.display = (G.rescues > 0 || G.buildings.beacon > 0 || G.buildings.meshNode > 0) ? 'block' : 'none'; + } set('r-rescues', G.rescues, G.rescuesRate); }