import fs from 'node:fs'; const js = fs.readFileSync(new URL('../game.js', import.meta.url), 'utf8'); const css = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8'); const html = fs.readFileSync(new URL('../index.html', import.meta.url), 'utf8'); const assets = new URL('../assets/', import.meta.url); const audio = new URL('../assets/audio/', import.meta.url); const referencedAudio = [...js.matchAll(/'assets\/audio\/([^']+)'/g)].map(match => match[1]); const roomWidth = Number(js.match(/ROOM_W = (\d+)/)?.[1]); const roomCount = Number(js.match(/ROOM_COUNT = (\d+)/)?.[1]); const arrayLiteral = name => { const marker = `const ${name} = [`; const start = js.indexOf(marker); if (start < 0) return null; 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); } return null; }; const roomLayouts = Function(`return ${arrayLiteral('ROOM_LAYOUTS')}`)(); const platformCount = roomLayouts.reduce((total, layout) => total + layout.ground.length + layout.ledges.length, 0); const countObjects = name => { const match = js.match(new RegExp(`const ${name} = \\[([\\s\\S]*?)\\n \\];`)); return match ? (match[1].match(/\{x:/g) || []).length : 0; }; const checks = [ ['world width >= 28800', roomWidth * roomCount >= 28800], ['four themed areas', (js.match(/\{start:\d+,end:/g) || []).length >= 4], ['ten lyric fragments', countObjects('fragments') >= 10], ['at least 84 platforms', platformCount >= 84], ['two checkpoint benches', countObjects('benches') >= 2], ['eight sparse readable memory terminals', countObjects('terminals') >= 8 && js.includes("target.kind==='terminal'")], ['memory arena gates', js.includes('memoryGates') && js.includes('memoryArenaActive')], ['boss arena gates', js.includes('arenaGates') && js.includes("'conductor'")], ['four regular enemy archetypes', ['shade','wisp','crawler','sentinel'].every(type => js.includes(`'${type}'`))], ['enemy finite-state behavior', js.includes("state:isBossType(type)?'boss':'idle'") && ['idle','patrol','alert','return'].every(state => js.includes(`'${state}'`))], ['enemy detection and alert memory', js.includes('updateEnemyAwareness') && js.includes('enemySightBlocked') && js.includes('lastSeenX')], ['ground enemy ledge avoidance', js.includes('groundAhead') && js.includes('moveGroundEnemySafely') && js.includes("if(wasGrounded&&intended&&!groundAhead")], ['enemy turn hysteresis', js.includes('turnLock') && js.includes('holdEnemyFacing') && js.includes('Math.abs(delta)>38')], ['enemy home-room containment', js.includes('containEnemyInHomeRoom') && js.includes('roomIndexAt(e.homeX)!==currentRoom')], ['interaction safe zones repel enemies', js.includes('safeZones') && js.includes('playerInSafeZone') && js.includes('repelEnemyFromSafeZones')], ['continuous sixteen-frame enemy animation', js.includes('drawAtlasSixteenPhase') && js.includes('sekai-enemies-16.png') && js.includes('length:16')], ['safe crawler pounce landing', js.includes('safePounceLanding') && js.includes("near>70&&near<350&&safePounceLanding")], ['enemy pit defeat handling', js.includes("!isBossType(e.type)&&e.y>H+120")], ['projectile combat', js.includes('updateProjectiles') && js.includes('drawProjectiles')], ['cinematic isolated-room transition', js.includes('startRoomTransition') && js.includes('drawRoomTransition') && js.includes('checkRoomBoundary')], ['five-step opening cinematic', js.includes('INTRO_SCENES') && (js.match(/chapter:/g) || []).length >= 5 && html.includes('introCg')], ['three AI prologue CGs', ['cg-prologue-nightcord.png','cg-prologue-arrival.png','cg-prologue-aquarium.png'].every(file=>fs.existsSync(new URL(file,assets))) && js.includes('cg-prologue-aquarium.png')], ['two AI ending CG branches', ['cg-ending-true.png','cg-ending-return.png'].every(file=>fs.existsSync(new URL(file,assets))) && js.includes("trueEnding?'assets/cg-ending-true.png':'assets/cg-ending-return.png'")], ['twelve-room exploration map', js.includes('ROOMS') && (js.match(/name:'[^']+',x:/g) || []).length >= 12 && html.includes('mapScreen')], ['persistent room discovery', js.includes('discoveredRooms:[...discoveredRooms]') && js.includes('discoverRoom(currentRoom)')], ['ability-driven backtracking loop', js.includes('if(!memoryArenaCleared)') && js.includes('返回沉水展厅') && js.includes('player.dashTimer>0')], ['paired two-way echo shortcuts', js.includes('const relays = [') && js.includes('candidate.pair===relay.pair')], ['AI boss sprite atlas', fs.existsSync(new URL('mafuyu-boss.png', assets)) && js.includes("assets/mafuyu-boss.png")], ['AI enemy 16-frame sprite atlas', fs.existsSync(new URL('sekai-enemies-16.png', assets)) && js.includes("assets/sekai-enemies-16.png") && js.includes('ENEMY_FRAMES')], ['AI interactable 16-frame sprite atlas', fs.existsSync(new URL('sekai-interactables-16.png', assets)) && js.includes("assets/sekai-interactables-16.png") && js.includes('INTERACTABLE_FRAMES')], ['Mafuyu interaction sprite atlas', fs.existsSync(new URL('mafuyu-interactions-normalized.png', assets)) && js.includes("assets/mafuyu-interactions-normalized.png")], ['front-facing bench sprite atlas', fs.existsSync(new URL('mafuyu-bench-front-normalized.png', assets)) && js.includes('benchFrontSprite') && js.includes('benchFrames(2)')], ['sixteen-frame Mafuyu ice-bow atlas', fs.existsSync(new URL('mafuyu-ice-bow.png', assets)) && js.includes('iceBow:{image:iceBowSprite') && js.includes('gridFrames16')], ['sixteen-frame Mafuyu normal attack atlas', fs.existsSync(new URL('mafuyu-attack-16.png', assets)) && js.includes("attack:{image:loadSprite('assets/mafuyu-attack-16.png')")], ['sixteen-frame charged ice-sword atlases', ['mafuyu-ice-charge.png','mafuyu-ice-release.png'].every(file=>fs.existsSync(new URL(file,assets))) && js.includes('CHARGE_FULL_TIME') && js.includes('updateChargedRelease')], ['PERFECT-powered freezing ice bow', js.includes('player.energy+25') && js.includes('function rangedAttack') && js.includes('freezeChance:FREEZE_CHANCE') && js.includes('cost=25')], ['four-frame short interactions', js.includes('interact:{image:interactionSprite,frames:normalizedFrames(0)}') && js.includes('sit:{image:benchFrontSprite,frames:benchFrames(0)}')], ['eight-frame front-facing rest loop', js.includes('rest:{image:benchFrontSprite,frames:[...benchFrames(1),...benchFrames(2)]}') && js.includes('%8')], ['room-local runtime caches', ['platformsByRoom','spikesByRoom','safeZonesByRoom','fragmentsByRoom'].every(name=>js.includes(name)) && !js.includes('const solids=[...platforms]')], ['bounded transient effects', ['MAX_PARTICLES','MAX_PROJECTILES','MAX_RESONANCE_SHOTS'].every(name=>js.includes(name))], ['forgiving platform input windows', js.includes('COYOTE_TIME = .14') && js.includes('JUMP_BUFFER_TIME = .15') && js.includes('ATTACK_BUFFER_TIME = .13')], ['player-only one-way thin platforms', js.includes('oneWay&&e===player') && js.includes('standingOnOneWay') && js.includes('player.dropTimer')], ['rhythm-safe hit stop and camera lookahead', js.includes('advanceRhythmClock(dt)') && js.includes('hitStop') && js.includes('cameraLookahead')], ['non-blocking tutorial room', html.includes('id="tutorialGuide"') && js.includes('TUTORIAL_LESSONS') && js.includes('trainingDummy') && js.includes('tutorial.flags.perfect')], ['dynamic Mafuyu portrait', fs.existsSync(new URL('mafuyu-portrait-normalized.png', assets)) && html.includes('id="characterPortrait"') && js.includes('updatePortrait') && css.includes('.character-portrait')], ['animated bench checkpoint flow', js.includes("beginPlayerAction('bench',bench,3.4)") && js.includes("player.action==='bench'") && js.includes('SEKAI 记忆已同步 · 生命完全恢复')], ['procedural enemies are fallback only', js.includes('drawEnemyFallback') && js.includes('if(!drawn)drawEnemyFallback(e)')], ['five local BGM tracks', ['bgm-empty.mp3','bgm-aquarium.mp3','bgm-corridor.mp3','bgm-stage.mp3','bgm-ending.mp3'].every(file => fs.existsSync(new URL(file, audio)))], ['gameplay SFX library', ['sfx-attack.ogg','sfx-hit.ogg','sfx-hurt.ogg','sfx-jump.ogg','sfx-dash.ogg','sfx-collect.ogg','sfx-boss-cast.ogg'].every(file => fs.existsSync(new URL(file, audio)))], ['crossfade audio system', js.includes('musicChannels') && js.includes('musicFade') && js.includes('updateAudio')], ['BGM playback failure can retry', js.includes("musicKey='';musicFade=null") && js.includes('ensureMusicPlaying') && !js.includes("pointerdown',()=>{unlockAudio();if(!running)playMusic('empty',.35);},{once:true}")], ['separate music and SFX volume', js.includes('musicVolumeInput') && js.includes('sfxVolumeInput')], ['main-menu settings surface', html.includes('id="settingsButton"') && html.includes('id="settingsScreen"') && html.includes('id="pauseSettingsButton"')], ['fullscreen settings control', html.includes('id="fullscreenButton"') && js.includes('requestFullscreen') && js.includes('fullscreenchange')], ['persistent control modes', html.includes('