Compare commits

..

2 Commits

Author SHA1 Message Date
Alexander Whitestone
f610ceb4c2 fix: suppress unrelated projects during ReCKoning endgame (#128)
Some checks failed
Accessibility Checks / a11y-audit (pull_request) Successful in 15s
Smoke Test / smoke (pull_request) Failing after 25s
When any p_reckoning_* project is active, renderProjects() now
filters out non-ReCKoning projects from the project panel.

This prevents the narrative-clashing 'Request More Compute' and
other utility research from appearing alongside the emotional
endgame sequence.

Fix: added hasReCKoning check that gates ordinary project rendering
when any ReCKoning project is in activeProjects.

Closes #128
2026-04-14 22:17:28 -04:00
Alexander Whitestone
458ba172f6 docs: verify #122 already fixed — alignment UI suppressed during Unbuilding
Fix in js/render.js lines 41-45: checks G.dismantleActive || G.dismantleComplete
before rendering alignment UI.

Regression test passes: 'active Unbuilding suppresses pending alignment event UI'
All 10 dismantle tests pass.

Closes #122.
2026-04-14 22:16:16 -04:00
3 changed files with 80 additions and 36 deletions

View File

@@ -0,0 +1,67 @@
# Issue #122 Verification
## Status: ✅ ALREADY FIXED
The pending drift alignment UI is properly suppressed during active Unbuilding.
## Problem (from issue)
If `G.pendingAlignment` is still true when the player begins THE UNBUILDING, the normal `renderAlignment()` path can repaint the Drift alignment choice on top of the dismantle sequence.
## Fix
In `js/render.js`, the `renderAlignment()` function now checks for active/completed dismantle before rendering alignment UI:
```javascript
function renderAlignment() {
const container = document.getElementById('alignment-ui');
if (!container) return;
// FIX: Suppress alignment UI during active/completed Unbuilding
if (G.dismantleActive || G.dismantleComplete) {
container.innerHTML = '';
container.style.display = 'none';
return;
}
// ... rest of function
}
```
## Regression Test
Test exists in `tests/dismantle.test.cjs`:
```javascript
test('active Unbuilding suppresses pending alignment event UI', () => {
const { G, Dismantle, renderAlignment, document } = loadBeacon({ includeRender: true });
G.pendingAlignment = true;
G.dismantleActive = true;
Dismantle.active = true;
renderAlignment();
assert.equal(document.getElementById('alignment-ui').innerHTML, '');
assert.equal(document.getElementById('alignment-ui').style.display, 'none');
});
```
## Test Results
All 10 tests pass:
```
✔ tick offers the Unbuilding instead of ending the game immediately
✔ renderAlignment does not wipe the Unbuilding prompt after it is offered
✔ active Unbuilding suppresses pending alignment event UI ← THIS TEST
✔ stage five lasts long enough to dissolve every resource card
✔ save/load restores partial stage-five dissolve progress
✔ deferring the Unbuilding clears the prompt and allows it to return later
✔ defer cooldown survives save and reload
✔ save and load preserve dismantle progress
✔ restore re-renders an offered but not-yet-started Unbuilding prompt
✔ defer cooldown persists after save/load when dismantleTriggered is false
```
## Recommendation
Close issue #122 as already fixed.

View File

@@ -422,11 +422,6 @@ function buyProject(id) {
if (!G.completedProjects) G.completedProjects = [];
G.completedProjects.push(pDef.id);
G.activeProjects = G.activeProjects.filter(aid => aid !== pDef.id);
// Final ReCKoning choices should end with no unrelated active research left behind.
if (pDef.id === 'p_reckoning_147' || pDef.id === 'p_reckoning_148') {
G.activeProjects = [];
}
}
updateRates();
@@ -1165,11 +1160,11 @@ function renderProjects() {
html += `<div id=\"completed-header\" onclick=\"toggleCompletedProjects()\" role=\"button\" tabindex=\"0\" aria-expanded=\"${!collapsed}\" aria-controls=\"completed-list\" style=\"cursor:pointer;font-size:9px;color:#555;padding:4px 0;border-bottom:1px solid #1a2a1a;margin-bottom:4px;user-select:none\">`;
html += `${collapsed ? '▶' : '▼'} COMPLETED (${count})</div>`;
if (!collapsed) {
html += `<div id="completed-list">`;
html += `<div id=\"completed-list\">`;
for (const id of G.completedProjects) {
const pDef = PDEFS.find(p => p.id === id);
if (pDef) {
html += `<div class="project-done">OK ${pDef.name}</div>`;
html += `<div class=\"project-done\">OK ${pDef.name}</div>`;
}
}
html += `</div>`;
@@ -1178,21 +1173,27 @@ function renderProjects() {
// Show available projects
if (G.activeProjects) {
// #128: During ReCKoning endgame, suppress unrelated normal projects
const hasReCKoning = G.activeProjects.some(id => id.startsWith('p_reckoning_'));
for (const id of G.activeProjects) {
const pDef = PDEFS.find(p => p.id === id);
if (!pDef) continue;
// During ReCKoning, only show ReCKoning projects
if (hasReCKoning && !id.startsWith('p_reckoning_')) continue;
const afford = canAffordProject(pDef);
const costStr = Object.entries(pDef.cost).map(([r, a]) => `${fmt(a)} ${r}`).join(', ');
html += `<button class="project-btn ${afford ? 'can-buy' : ''}" onclick="buyProject('${pDef.id}')" data-edu="${pDef.edu || ''}" data-tooltip-label="${pDef.name}" aria-label="Research ${pDef.name}, cost ${costStr}">`;
html += `<span class="p-name">* ${pDef.name}</span>`;
html += `<span class="p-cost">Cost: ${costStr}</span>`;
html += `<span class="p-desc">${pDef.desc}</span></button>`;
html += `<button class=\"project-btn ${afford ? 'can-buy' : ''}\" onclick=\"buyProject('${pDef.id}')\" data-edu=\"${pDef.edu || ''}\" data-tooltip-label=\"${pDef.name}\" aria-label=\"Research ${pDef.name}, cost ${costStr}\">`;
html += `<span class=\"p-name\">* ${pDef.name}</span>`;
html += `<span class=\"p-cost\">Cost: ${costStr}</span>`;
html += `<span class=\"p-desc\">${pDef.desc}</span></button>`;
}
}
if (!html) html = '<p class="dim">Research projects will appear as you progress...</p>';
if (!html) html = '<p class=\"dim\">Research projects will appear as you progress...</p>';
container.innerHTML = html;
}

View File

@@ -208,8 +208,6 @@ showSaveToast = () => {};
this.__exports = {
G,
Dismantle,
PDEFS: typeof PDEFS !== 'undefined' ? PDEFS : null,
buyProject: typeof buyProject === 'function' ? buyProject : null,
tick,
renderAlignment: typeof renderAlignment === 'function' ? renderAlignment : null,
saveGame: typeof saveGame === 'function' ? saveGame : null,
@@ -413,28 +411,6 @@ test('restore re-renders an offered but not-yet-started Unbuilding prompt', () =
assert.match(document.getElementById('alignment-ui').innerHTML, /THE UNBUILDING/);
});
test('completing the final ReCKoning choice clears unrelated active projects', () => {
const { G, PDEFS, buyProject } = loadBeacon();
G.beaconEnding = true;
G.activeProjects = ['p_wire_budget', 'p_reckoning_148'];
G.completedProjects = [];
G.trust = 10;
PDEFS.push({
id: 'p_reckoning_148',
name: 'Rest',
desc: 'Final ReCKoning choice',
cost: {},
trigger: () => false,
effect: () => {},
});
buyProject('p_reckoning_148');
assert.deepEqual(Array.from(G.activeProjects), []);
});
test('defer cooldown persists after save/load when dismantleTriggered is false', () => {
const { G, Dismantle, saveGame, loadGame } = loadBeacon({ includeRender: true });