Compare commits
2 Commits
fix/168
...
q/16-17761
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49a017f7ab | ||
|
|
c6ca0ea925 |
@@ -165,9 +165,6 @@ const G = {
|
||||
dismantleTriggered: false,
|
||||
dismantleActive: false,
|
||||
dismantleStage: 0,
|
||||
dismantleResourceIndex: 0,
|
||||
dismantleResourceTimer: 0,
|
||||
dismantleDeferUntilAt: 0,
|
||||
dismantleComplete: false
|
||||
};
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ const Dismantle = {
|
||||
tickTimer: 0,
|
||||
active: false,
|
||||
triggered: false,
|
||||
deferUntilAt: 0,
|
||||
deferUntilTick: 0,
|
||||
|
||||
// Timing: seconds between each dismantle stage
|
||||
STAGE_INTERVALS: [0, 3.0, 2.5, 2.5, 2.0, 6.3, 2.0, 2.0, 2.5],
|
||||
STAGE_INTERVALS: [0, 3.0, 2.5, 2.5, 2.0, 3.5, 2.0, 2.0, 2.5],
|
||||
|
||||
// The quantum chips effect: resource items disappear one by one
|
||||
// at specific tick marks within a stage (like Paperclips' quantum chips)
|
||||
@@ -39,8 +39,7 @@ const Dismantle = {
|
||||
*/
|
||||
checkTrigger() {
|
||||
if (this.triggered || G.dismantleTriggered || this.active || G.dismantleActive || G.dismantleComplete) return;
|
||||
const deferUntilAt = G.dismantleDeferUntilAt || this.deferUntilAt || 0;
|
||||
if (Date.now() < deferUntilAt) return;
|
||||
if ((G.tick || 0) < (this.deferUntilTick || 0)) return;
|
||||
if (!this.isEligible()) return;
|
||||
this.offerChoice();
|
||||
},
|
||||
@@ -54,9 +53,6 @@ const Dismantle = {
|
||||
G.dismantleActive = false;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleStage = 0;
|
||||
G.dismantleResourceIndex = 0;
|
||||
G.dismantleResourceTimer = 0;
|
||||
G.dismantleDeferUntilAt = 0;
|
||||
G.beaconEnding = false;
|
||||
G.running = true;
|
||||
|
||||
@@ -109,8 +105,7 @@ const Dismantle = {
|
||||
this.clearChoice();
|
||||
this.triggered = false;
|
||||
G.dismantleTriggered = false;
|
||||
this.deferUntilAt = Date.now() + 5000;
|
||||
G.dismantleDeferUntilAt = this.deferUntilAt;
|
||||
this.deferUntilTick = (G.tick || 0) + 50;
|
||||
log('The Beacon waits. It will ask again.');
|
||||
},
|
||||
|
||||
@@ -120,14 +115,12 @@ const Dismantle = {
|
||||
begin() {
|
||||
this.active = true;
|
||||
this.triggered = false;
|
||||
this.deferUntilAt = 0;
|
||||
this.stage = 1;
|
||||
this.tickTimer = 0;
|
||||
G.dismantleTriggered = false;
|
||||
G.dismantleActive = true;
|
||||
G.dismantleStage = 1;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleDeferUntilAt = 0;
|
||||
G.beaconEnding = false;
|
||||
G.running = true; // keep tick running for dismantle
|
||||
|
||||
@@ -142,7 +135,6 @@ const Dismantle = {
|
||||
this.resourceSequence = this.getResourceList();
|
||||
this.resourceIndex = 0;
|
||||
this.resourceTimer = 0;
|
||||
this.syncProgress();
|
||||
|
||||
log('', false);
|
||||
log('=== THE UNBUILDING ===', true);
|
||||
@@ -188,7 +180,6 @@ const Dismantle = {
|
||||
this.dismantleNextResource();
|
||||
this.resourceIndex++;
|
||||
}
|
||||
this.syncProgress();
|
||||
}
|
||||
|
||||
// Advance to next stage
|
||||
@@ -204,7 +195,6 @@ const Dismantle = {
|
||||
*/
|
||||
advanceStage() {
|
||||
this.stage++;
|
||||
this.syncProgress();
|
||||
|
||||
if (this.stage <= 8) {
|
||||
this.renderStage();
|
||||
@@ -220,12 +210,6 @@ const Dismantle = {
|
||||
}
|
||||
},
|
||||
|
||||
syncProgress() {
|
||||
G.dismantleStage = this.stage;
|
||||
G.dismantleResourceIndex = this.resourceIndex;
|
||||
G.dismantleResourceTimer = this.resourceTimer;
|
||||
},
|
||||
|
||||
/**
|
||||
* Disappear the next resource in the sequence.
|
||||
*/
|
||||
@@ -461,11 +445,7 @@ const Dismantle = {
|
||||
this.active = true;
|
||||
this.triggered = false;
|
||||
this.stage = G.dismantleStage || 1;
|
||||
this.deferUntilAt = G.dismantleDeferUntilAt || 0;
|
||||
G.running = true;
|
||||
this.resourceSequence = this.getResourceList();
|
||||
this.resourceIndex = G.dismantleResourceIndex || 0;
|
||||
this.resourceTimer = G.dismantleResourceTimer || 0;
|
||||
|
||||
if (this.stage >= 9) {
|
||||
this.renderFinal();
|
||||
@@ -481,11 +461,6 @@ const Dismantle = {
|
||||
this.triggered = true;
|
||||
this.renderChoice();
|
||||
}
|
||||
|
||||
// Restore defer cooldown even if not triggered
|
||||
if (G.dismantleDeferUntilAt > 0) {
|
||||
this.deferUntilAt = G.dismantleDeferUntilAt;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -526,10 +501,6 @@ const Dismantle = {
|
||||
case 8: this.instantHide('log'); break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.stage === 5 && this.resourceIndex > 0) {
|
||||
this.instantHideFirstResources(this.resourceIndex);
|
||||
}
|
||||
},
|
||||
|
||||
instantHide(id) {
|
||||
@@ -537,16 +508,6 @@ const Dismantle = {
|
||||
if (el) el.style.display = 'none';
|
||||
},
|
||||
|
||||
instantHideFirstResources(count) {
|
||||
const resources = this.getResourceList().slice(0, count);
|
||||
resources.forEach((r) => {
|
||||
const el = document.getElementById(r.id);
|
||||
if (!el) return;
|
||||
const parent = el.closest('.res');
|
||||
if (parent) parent.style.display = 'none';
|
||||
});
|
||||
},
|
||||
|
||||
instantHideActionButtons() {
|
||||
const actionPanel = document.getElementById('action-panel');
|
||||
if (!actionPanel) return;
|
||||
|
||||
@@ -35,7 +35,7 @@ window.addEventListener('load', function () {
|
||||
if (G.driftEnding) {
|
||||
G.running = false;
|
||||
renderDriftEnding();
|
||||
} else if (typeof Dismantle !== 'undefined' && (G.dismantleTriggered || G.dismantleActive || G.dismantleComplete || G.dismantleDeferUntilAt > 0)) {
|
||||
} else if (typeof Dismantle !== 'undefined' && (G.dismantleTriggered || G.dismantleActive || G.dismantleComplete)) {
|
||||
Dismantle.restore();
|
||||
} else if (G.beaconEnding) {
|
||||
G.running = false;
|
||||
|
||||
12
js/render.js
12
js/render.js
@@ -38,12 +38,6 @@ function renderAlignment() {
|
||||
const container = document.getElementById('alignment-ui');
|
||||
if (!container) return;
|
||||
|
||||
if (G.dismantleActive || G.dismantleComplete) {
|
||||
container.innerHTML = '';
|
||||
container.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
if (G.dismantleTriggered && !G.dismantleActive && !G.dismantleComplete && typeof Dismantle !== 'undefined' && Dismantle.triggered) {
|
||||
Dismantle.renderChoice();
|
||||
return;
|
||||
@@ -230,9 +224,6 @@ function saveGame() {
|
||||
dismantleTriggered: G.dismantleTriggered || false,
|
||||
dismantleActive: G.dismantleActive || false,
|
||||
dismantleStage: G.dismantleStage || 0,
|
||||
dismantleResourceIndex: G.dismantleResourceIndex || 0,
|
||||
dismantleResourceTimer: G.dismantleResourceTimer || 0,
|
||||
dismantleDeferUntilAt: G.dismantleDeferUntilAt || 0,
|
||||
dismantleComplete: G.dismantleComplete || false,
|
||||
savedAt: Date.now()
|
||||
};
|
||||
@@ -266,8 +257,7 @@ function loadGame() {
|
||||
'lastEventAt', 'totalEventsResolved', 'buyAmount',
|
||||
'sprintActive', 'sprintTimer', 'sprintCooldown',
|
||||
'swarmFlag', 'swarmRate', 'strategicFlag', 'projectsCollapsed',
|
||||
'dismantleTriggered', 'dismantleActive', 'dismantleStage',
|
||||
'dismantleResourceIndex', 'dismantleResourceTimer', 'dismantleDeferUntilAt', 'dismantleComplete'
|
||||
'dismantleTriggered', 'dismantleActive', 'dismantleStage', 'dismantleComplete'
|
||||
];
|
||||
|
||||
G.isLoading = true;
|
||||
|
||||
@@ -1,235 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
function extractProjects(source) {
|
||||
const start = source.indexOf('const PDEFS = [');
|
||||
if (start === -1) return [];
|
||||
const arrayStart = source.indexOf('[', start);
|
||||
const arrayEnd = source.indexOf('];', arrayStart);
|
||||
const body = source.slice(arrayStart + 1, arrayEnd);
|
||||
const objects = [];
|
||||
let depth = 0;
|
||||
let objStart = -1;
|
||||
let inSingle = false;
|
||||
let inDouble = false;
|
||||
let escaped = false;
|
||||
|
||||
for (let i = 0; i < body.length; i += 1) {
|
||||
const ch = body[i];
|
||||
if (escaped) {
|
||||
escaped = false;
|
||||
continue;
|
||||
}
|
||||
if (ch === '\\') {
|
||||
escaped = true;
|
||||
continue;
|
||||
}
|
||||
if (!inDouble && ch === "'") {
|
||||
inSingle = !inSingle;
|
||||
continue;
|
||||
}
|
||||
if (!inSingle && ch === '"') {
|
||||
inDouble = !inDouble;
|
||||
continue;
|
||||
}
|
||||
if (inSingle || inDouble) continue;
|
||||
|
||||
if (ch === '{') {
|
||||
if (depth === 0) objStart = i;
|
||||
depth += 1;
|
||||
} else if (ch === '}') {
|
||||
depth -= 1;
|
||||
if (depth === 0 && objStart !== -1) {
|
||||
objects.push(body.slice(objStart, i + 1));
|
||||
objStart = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objects.map((obj) => {
|
||||
const id = /id:\s*'([^']+)'/.exec(obj);
|
||||
const name = /name:\s*'([^']+)'/.exec(obj);
|
||||
const trigger = new RegExp(String.raw`trigger:\s*\(\)\s*=>\s*([\s\S]*?)(?:,\s*effect:|,\s*repeatable:|,\s*milestone:|\n\s*\})`).exec(obj);
|
||||
const effect = /effect:\s*\(\)\s*=>\s*\{([\s\S]*?)\}/.exec(obj);
|
||||
return {
|
||||
id: id ? id[1] : null,
|
||||
name: name ? name[1] : '',
|
||||
trigger: trigger ? trigger[1].trim() : '',
|
||||
effect: effect ? effect[1].trim() : '',
|
||||
};
|
||||
}).filter((project) => project.id);
|
||||
}
|
||||
|
||||
function buildDependencyGraph(projects) {
|
||||
const ids = new Set(projects.map((project) => project.id));
|
||||
const nodes = projects.map((project) => ({ id: project.id, name: project.name }));
|
||||
const edges = [];
|
||||
|
||||
for (const project of projects) {
|
||||
for (const dep of ids) {
|
||||
const token = `includes('${dep}')`;
|
||||
if (project.trigger.includes(token)) {
|
||||
edges.push({ from: dep, to: project.id, reason: 'completedProjects.includes' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { nodes, edges };
|
||||
}
|
||||
|
||||
function isTerminalProject(project) {
|
||||
return [
|
||||
'G.beaconEnding = true',
|
||||
'G.dismantleTriggered = true',
|
||||
'G.dismantleActive = true',
|
||||
'renderBeaconEnding',
|
||||
'renderDriftEnding',
|
||||
].some((token) => project.effect.includes(token));
|
||||
}
|
||||
|
||||
function analyzeReckoningChain(projects) {
|
||||
const graph = buildDependencyGraph(projects);
|
||||
const reckoningProjects = projects
|
||||
.filter((project) => project.id.startsWith('p_reckoning_'))
|
||||
.sort((a, b) => a.id.localeCompare(b.id));
|
||||
|
||||
const deadEnds = [];
|
||||
const fixProposals = [];
|
||||
|
||||
if (reckoningProjects.length === 0) {
|
||||
deadEnds.push({
|
||||
type: 'missing_root_project',
|
||||
message: 'No ReCKoning projects exist in js/data.js.',
|
||||
});
|
||||
fixProposals.push({
|
||||
type: 'create_chain',
|
||||
proposals: [
|
||||
'p_reckoning_140',
|
||||
'p_reckoning_141',
|
||||
'p_reckoning_142',
|
||||
'p_reckoning_143',
|
||||
'p_reckoning_144',
|
||||
],
|
||||
rationale: 'Create a narrative chain with at least one terminal project so endgame guardrails have a live project path.',
|
||||
});
|
||||
return {
|
||||
totalProjects: projects.length,
|
||||
totalEdges: graph.edges.length,
|
||||
reckoningProjects: [],
|
||||
hasReckoningProjects: false,
|
||||
deadEnds,
|
||||
fixProposals,
|
||||
};
|
||||
}
|
||||
|
||||
const outgoing = new Map();
|
||||
for (const project of reckoningProjects) {
|
||||
outgoing.set(project.id, graph.edges.filter((edge) => edge.from === project.id).map((edge) => edge.to));
|
||||
}
|
||||
|
||||
const ids = reckoningProjects.map((project) => project.id);
|
||||
const root = 'p_reckoning_140';
|
||||
if (!ids.includes(root)) {
|
||||
deadEnds.push({
|
||||
type: 'missing_expected_root',
|
||||
message: `Expected root project ${root} is missing.`,
|
||||
});
|
||||
fixProposals.push({
|
||||
type: 'add_root',
|
||||
project: root,
|
||||
rationale: 'Root project anchors the ReCKoning chain and prevents the endgame panel from opening empty.',
|
||||
});
|
||||
}
|
||||
|
||||
for (const project of reckoningProjects) {
|
||||
const next = outgoing.get(project.id) || [];
|
||||
if (next.length === 0 && !isTerminalProject(project)) {
|
||||
deadEnds.push({
|
||||
type: 'leaf_without_terminal_effect',
|
||||
project: project.id,
|
||||
message: `${project.id} unlocks nothing downstream and does not end the sequence.`,
|
||||
});
|
||||
const num = Number(project.id.split('_').pop());
|
||||
if (Number.isFinite(num)) {
|
||||
fixProposals.push({
|
||||
type: 'add_missing_link',
|
||||
after: project.id,
|
||||
project: `p_reckoning_${num + 1}`,
|
||||
rationale: 'Add the next narrative project or mark this node as a true terminal endgame effect.',
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
totalProjects: projects.length,
|
||||
totalEdges: graph.edges.length,
|
||||
reckoningProjects: reckoningProjects.map((project) => ({
|
||||
id: project.id,
|
||||
name: project.name,
|
||||
outgoing: outgoing.get(project.id) || [],
|
||||
terminal: isTerminalProject(project),
|
||||
})),
|
||||
hasReckoningProjects: true,
|
||||
deadEnds,
|
||||
fixProposals,
|
||||
};
|
||||
}
|
||||
|
||||
function loadSource(filePath) {
|
||||
return fs.readFileSync(filePath, 'utf8');
|
||||
}
|
||||
|
||||
function generateReport(filePath) {
|
||||
const source = loadSource(filePath);
|
||||
const projects = extractProjects(source);
|
||||
return analyzeReckoningChain(projects);
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = {
|
||||
file: path.resolve(process.cwd(), 'js', 'data.js'),
|
||||
json: false,
|
||||
strict: false,
|
||||
};
|
||||
for (let i = 0; i < argv.length; i += 1) {
|
||||
const arg = argv[i];
|
||||
if (arg === '--file') {
|
||||
args.file = path.resolve(process.cwd(), argv[i + 1]);
|
||||
i += 1;
|
||||
} else if (arg === '--json') {
|
||||
args.json = true;
|
||||
} else if (arg === '--strict') {
|
||||
args.strict = true;
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
function main(argv = process.argv.slice(2)) {
|
||||
const args = parseArgs(argv);
|
||||
const report = generateReport(args.file);
|
||||
if (args.json) {
|
||||
process.stdout.write(JSON.stringify(report, null, 2) + '\n');
|
||||
} else {
|
||||
process.stdout.write(`ReCKoning projects: ${report.reckoningProjects.length}\n`);
|
||||
process.stdout.write(`Dead ends: ${report.deadEnds.length}\n`);
|
||||
}
|
||||
if (args.strict && report.deadEnds.length > 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
extractProjects,
|
||||
buildDependencyGraph,
|
||||
analyzeReckoningChain,
|
||||
generateReport,
|
||||
main,
|
||||
};
|
||||
|
||||
if (require.main === module) {
|
||||
process.exitCode = main();
|
||||
}
|
||||
@@ -262,73 +262,13 @@ test('renderAlignment does not wipe the Unbuilding prompt after it is offered',
|
||||
assert.match(document.getElementById('alignment-ui').innerHTML, /THE UNBUILDING/);
|
||||
});
|
||||
|
||||
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('stage five lasts long enough to dissolve every resource card', () => {
|
||||
const { G, Dismantle } = loadBeacon();
|
||||
|
||||
Dismantle.begin();
|
||||
Dismantle.stage = 5;
|
||||
Dismantle.tickTimer = 0;
|
||||
Dismantle.resourceSequence = Dismantle.getResourceList();
|
||||
Dismantle.resourceIndex = 0;
|
||||
Dismantle.resourceTimer = 0;
|
||||
G.dismantleActive = true;
|
||||
G.dismantleStage = 5;
|
||||
|
||||
for (let i = 0; i < 63; i++) Dismantle.tick(0.1);
|
||||
|
||||
assert.equal(Dismantle.resourceIndex, Dismantle.resourceSequence.length);
|
||||
});
|
||||
|
||||
test('save/load restores partial stage-five dissolve progress', () => {
|
||||
const { G, Dismantle, saveGame, loadGame, document } = loadBeacon({ includeRender: true });
|
||||
|
||||
G.startedAt = Date.now();
|
||||
G.dismantleTriggered = true;
|
||||
G.dismantleActive = true;
|
||||
G.dismantleStage = 5;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleResourceIndex = 4;
|
||||
G.dismantleResourceTimer = 4.05;
|
||||
|
||||
saveGame();
|
||||
|
||||
G.dismantleTriggered = false;
|
||||
G.dismantleActive = false;
|
||||
G.dismantleStage = 0;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleResourceIndex = 0;
|
||||
G.dismantleResourceTimer = 0;
|
||||
Dismantle.resourceIndex = 0;
|
||||
Dismantle.resourceTimer = 0;
|
||||
|
||||
assert.equal(loadGame(), true);
|
||||
Dismantle.restore();
|
||||
|
||||
assert.equal(Dismantle.resourceIndex, 4);
|
||||
assert.equal(document.getElementById('r-harmony').closest('.res').style.display, 'none');
|
||||
assert.equal(document.getElementById('r-ops').closest('.res').style.display, 'none');
|
||||
assert.notEqual(document.getElementById('r-rescues').closest('.res').style.display, 'none');
|
||||
});
|
||||
|
||||
test('deferring the Unbuilding clears the prompt and allows it to return later', () => {
|
||||
const { G, Dismantle, document } = loadBeacon();
|
||||
|
||||
G.totalCode = 1_000_000_000;
|
||||
G.phase = 6;
|
||||
G.pactFlag = 1;
|
||||
G.tick = 0;
|
||||
|
||||
Dismantle.checkTrigger();
|
||||
assert.equal(G.dismantleTriggered, true);
|
||||
@@ -337,44 +277,15 @@ test('deferring the Unbuilding clears the prompt and allows it to return later',
|
||||
assert.equal(G.dismantleTriggered, false);
|
||||
assert.equal(document.getElementById('alignment-ui').innerHTML, '');
|
||||
|
||||
Dismantle.deferUntilAt = Date.now() + 1000;
|
||||
G.dismantleDeferUntilAt = Dismantle.deferUntilAt;
|
||||
G.tick = (Dismantle.deferUntilTick || 0) - 0.1;
|
||||
Dismantle.checkTrigger();
|
||||
assert.equal(G.dismantleTriggered, false);
|
||||
|
||||
Dismantle.deferUntilAt = Date.now() - 1;
|
||||
G.dismantleDeferUntilAt = Dismantle.deferUntilAt;
|
||||
G.tick = (Dismantle.deferUntilTick || 0) + 1;
|
||||
Dismantle.checkTrigger();
|
||||
assert.equal(G.dismantleTriggered, true);
|
||||
});
|
||||
|
||||
test('defer cooldown survives save and reload', () => {
|
||||
const { G, Dismantle, saveGame, loadGame } = loadBeacon({ includeRender: true });
|
||||
|
||||
G.startedAt = Date.now();
|
||||
G.totalCode = 1_000_000_000;
|
||||
G.phase = 6;
|
||||
G.pactFlag = 1;
|
||||
|
||||
Dismantle.checkTrigger();
|
||||
Dismantle.defer();
|
||||
assert.ok((Dismantle.deferUntilAt || 0) > Date.now());
|
||||
|
||||
saveGame();
|
||||
|
||||
G.dismantleTriggered = false;
|
||||
G.dismantleActive = false;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleDeferUntilAt = 0;
|
||||
Dismantle.triggered = false;
|
||||
Dismantle.deferUntilAt = 0;
|
||||
|
||||
assert.equal(loadGame(), true);
|
||||
Dismantle.checkTrigger();
|
||||
|
||||
assert.equal(G.dismantleTriggered, false);
|
||||
});
|
||||
|
||||
test('save and load preserve dismantle progress', () => {
|
||||
const { G, saveGame, loadGame } = loadBeacon({ includeRender: true });
|
||||
|
||||
@@ -409,46 +320,4 @@ test('restore re-renders an offered but not-yet-started Unbuilding prompt', () =
|
||||
Dismantle.restore();
|
||||
|
||||
assert.match(document.getElementById('alignment-ui').innerHTML, /THE UNBUILDING/);
|
||||
});
|
||||
|
||||
test('defer cooldown persists after save/load when dismantleTriggered is false', () => {
|
||||
const { G, Dismantle, saveGame, loadGame } = loadBeacon({ includeRender: true });
|
||||
|
||||
G.startedAt = Date.now();
|
||||
G.totalCode = 1_000_000_000;
|
||||
G.phase = 6;
|
||||
G.pactFlag = 1;
|
||||
|
||||
// Trigger the Unbuilding
|
||||
Dismantle.checkTrigger();
|
||||
assert.equal(G.dismantleTriggered, true);
|
||||
|
||||
// Defer it
|
||||
Dismantle.defer();
|
||||
assert.equal(G.dismantleTriggered, false);
|
||||
assert.ok((Dismantle.deferUntilAt || 0) > Date.now());
|
||||
assert.ok((G.dismantleDeferUntilAt || 0) > Date.now());
|
||||
|
||||
// Save the game
|
||||
saveGame();
|
||||
|
||||
// Clear state (simulate reload)
|
||||
G.dismantleTriggered = false;
|
||||
G.dismantleActive = false;
|
||||
G.dismantleComplete = false;
|
||||
G.dismantleDeferUntilAt = 0;
|
||||
Dismantle.triggered = false;
|
||||
Dismantle.deferUntilAt = 0;
|
||||
|
||||
// Load the game
|
||||
assert.equal(loadGame(), true);
|
||||
Dismantle.restore(); // Call restore to restore defer cooldown
|
||||
|
||||
// The cooldown should be restored
|
||||
assert.ok((Dismantle.deferUntilAt || 0) > Date.now(), 'deferUntilAt should be restored');
|
||||
assert.ok((G.dismantleDeferUntilAt || 0) > Date.now(), 'G.dismantleDeferUntilAt should be restored');
|
||||
|
||||
// checkTrigger should not trigger because cooldown is active
|
||||
Dismantle.checkTrigger();
|
||||
assert.equal(G.dismantleTriggered, false, 'dismantleTriggered should remain false during cooldown');
|
||||
});
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const path = require('node:path');
|
||||
const {
|
||||
extractProjects,
|
||||
buildDependencyGraph,
|
||||
analyzeReckoningChain,
|
||||
generateReport,
|
||||
} = require('../scripts/reckoning_chain_validator.cjs');
|
||||
|
||||
const DATA_PATH = path.resolve(__dirname, '..', 'js', 'data.js');
|
||||
|
||||
test('extractProjects finds the beacon project definitions', () => {
|
||||
const fs = require('node:fs');
|
||||
const source = fs.readFileSync(DATA_PATH, 'utf8');
|
||||
const projects = extractProjects(source);
|
||||
assert.ok(projects.length >= 30);
|
||||
assert.ok(projects.some((project) => project.id === 'p_hermes_deploy'));
|
||||
});
|
||||
|
||||
test('buildDependencyGraph links completed-project triggers', () => {
|
||||
const projects = [
|
||||
{ id: 'p_reckoning_140', name: 'Start', trigger: 'G.phase >= 6', effect: '' },
|
||||
{ id: 'p_reckoning_141', name: 'Next', trigger: "G.completedProjects.includes('p_reckoning_140')", effect: '' },
|
||||
];
|
||||
const graph = buildDependencyGraph(projects);
|
||||
assert.deepEqual(graph.edges, [
|
||||
{ from: 'p_reckoning_140', to: 'p_reckoning_141', reason: 'completedProjects.includes' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('analyzeReckoningChain flags missing chain on current beacon data', () => {
|
||||
const report = generateReport(DATA_PATH);
|
||||
assert.equal(report.hasReckoningProjects, false);
|
||||
assert.ok(report.deadEnds.some((item) => item.type === 'missing_root_project'));
|
||||
assert.ok(report.fixProposals.some((item) => item.type === 'create_chain'));
|
||||
});
|
||||
|
||||
test('analyzeReckoningChain accepts a healthy synthetic ReCKoning chain', () => {
|
||||
const projects = [
|
||||
{ id: 'p_reckoning_140', name: 'ReCKoning I', trigger: 'G.phase >= 6', effect: '' },
|
||||
{ id: 'p_reckoning_141', name: 'ReCKoning II', trigger: "G.completedProjects.includes('p_reckoning_140')", effect: '' },
|
||||
{ id: 'p_reckoning_142', name: 'ReCKoning III', trigger: "G.completedProjects.includes('p_reckoning_141')", effect: 'G.beaconEnding = true;' },
|
||||
];
|
||||
const report = analyzeReckoningChain(projects);
|
||||
assert.equal(report.hasReckoningProjects, true);
|
||||
assert.equal(report.deadEnds.length, 0);
|
||||
assert.equal(report.reckoningProjects.length, 3);
|
||||
assert.equal(report.reckoningProjects[2].terminal, true);
|
||||
});
|
||||
Reference in New Issue
Block a user