Files
mfyheart/tools/check_campaign.mjs
T

64 lines
3.7 KiB
JavaScript

import fs from 'node:fs';
const js = fs.readFileSync(new URL('../game.js', import.meta.url), 'utf8');
const html = fs.readFileSync(new URL('../index.html', import.meta.url), 'utf8');
const assets = new URL('../assets/', import.meta.url);
function arrayLiteral(name) {
const marker = `const ${name} = [`;
const start = js.indexOf(marker);
if (start < 0) throw new Error(`Missing ${name}`);
const bodyStart = start + marker.length - 1;
let depth = 0;
for (let index = bodyStart; index < js.length; index++) {
if (js[index] === '[') depth++;
if (js[index] === ']' && --depth === 0) return js.slice(bodyStart, index + 1);
}
throw new Error(`Unclosed ${name}`);
}
const rooms = Function(`return ${arrayLiteral('ROOMS')}`)();
const areas = Function(`return ${arrayLiteral('areas')}`)();
const fragments = Function(`return ${arrayLiteral('fragments')}`)();
const lamps = Function(`return ${arrayLiteral('memoryLamps')}`)();
const terminals = Function(`return ${arrayLiteral('terminals')}`)();
const benches = Function(`return ${arrayLiteral('benches')}`)();
const normalEnemyCount = (js.match(/makeEnemy\(\d+/g) || []).length - 2;
// Conservative authored-content pacing model. This is not a forced timer:
// it estimates first-play exploration, fights, two bosses, reading and the
// ability-driven return routes from the amount of shipped content.
const estimatedMinutes = rooms.length * 1.65 + normalEnemyCount * 0.34 + 10 + 8
+ (fragments.length + lamps.length + terminals.length) * 0.16;
const assetNames = [
'sekai-expansion-enemies-16.png',
'sekai-expansion-interactables-16.png',
'mafuyu-final-boss-16.png',
'expansion-animation-preview.png'
];
const checks = [
['twenty isolated exploration rooms', rooms.length === 20 && js.includes('ROOM_COUNT = 20')],
['six themed areas', areas.length === 6],
['eighteen lyric fragments', fragments.length === 18],
['six optional rain-memory lamps', lamps.length === 6 && js.includes("target.kind==='lamp'")],
['eight readable memory terminals', terminals.length === 8],
['six or more checkpoint benches', benches.length >= 6],
['four expansion enemy archetypes', ['maskling','metronome','rainChoir','mirrorHound'].every(type => js.includes(`'${type}'`))],
['distinct expansion enemy behaviors', ['blade','rain','safePounceLanding'].every(token => js.includes(token))],
['mid-boss and final boss progression', js.includes('midBossDefeated') && js.includes("type==='mirror'") && js.includes('finalArenaActive')],
['second movement ability and gate', js.includes('hasDoubleJump') && js.includes('airJumps') && js.includes('mobilityGate')],
['version-seven extended save data', js.includes('version:7') && ['playTime','lamps','storyFlags','hasDoubleJump'].every(key => js.includes(key))],
['DOM field journal', html.includes('id="journalScreen"') && html.includes('id="journalAbilities"') && js.includes('toggleJournal')],
['desktop and touch journal controls', html.includes('data-touch-action="journal"') && js.includes("e.code==='KeyQ'")],
['all expansion atlases exist', assetNames.every(name => fs.existsSync(new URL(name, assets)))],
['sixteen-frame expansion atlases wired', js.includes('EXPANSION_ENEMY_FRAMES') && js.includes('FINAL_BOSS_FRAMES') && js.includes('length:16')],
['first-play content estimate at least sixty minutes', estimatedMinutes >= 60]
];
console.log(`Authored first-play estimate: ${estimatedMinutes.toFixed(1)} minutes`);
console.log(`Rooms ${rooms.length}; regular enemies ${normalEnemyCount}; lore/reward interactions ${fragments.length + lamps.length + terminals.length}`);
for (const [label, passed] of checks) console.log(`${passed ? 'PASS' : 'FAIL'} ${label}`);
if (checks.some(([, passed]) => !passed)) process.exitCode = 1;