2026-07-18 13:06:02 +09:00
"use strict" ;
const fs = require ( "fs" ) ;
function ok ( cond , msg ) { if ( ! cond ) throw new Error ( msg ) ; console . log ( ` [OK] ${ msg } ` ) ; }
const sim = fs . readFileSync ( "js/simulation_effects_system.js" , "utf8" ) ;
const combat = fs . readFileSync ( "js/world_combat_effects.js" , "utf8" ) ;
const all = fs . readdirSync ( "js" ) . filter ( x => x . endsWith ( ".js" ) ) . map ( x => fs . readFileSync ( ` js/ ${ x } ` , "utf8" ) ) . join ( "\n" ) ;
ok ( ! /\.map\([\s\S]{0,300}\.sort\(/ . test ( sim ) , "effect pressure compaction no longer map/sorts all effects" ) ;
ok ( sim . includes ( "for (let priority = 1; priority <= 3" ) , "effect pressure drops by priority tiers" ) ;
2026-07-18 22:15:26 +09:00
ok ( combat . includes ( '"bleed", "bubble", "eat", "explosion", "heart", "shoot_impact", "zunchi_miasma", "electric_shock", "wind"' ) , "all transient effect variants use the reusable pool path" ) ;
2026-07-18 13:06:02 +09:00
ok ( combat . includes ( "offscreenCulled" ) , "low-importance offscreen spawns are tracked and culled" ) ;
2026-07-18 22:15:26 +09:00
ok ( combat . includes ( 'visualLevel?.("effects", "high") === "off"' ) , "effect creation is gated by the visual-effects setting" ) ;
ok ( sim . includes ( 'visualLevel?.("effects", "high") === "off"' ) && sim . includes ( "clearDisabledEffects" ) , "disabled effects are released instead of updated" ) ;
2026-07-18 13:06:02 +09:00
ok ( sim . includes ( 'if (effect.type === "ring")' ) && sim . includes ( "lightweight" ) , "rings bypass the budgeted physics update path" ) ;
2026-07-18 22:15:26 +09:00
ok ( ! sim . includes ( "const budgeted = []" ) , "effect updates do not allocate a temporary active-effect array each frame" ) ;
2026-07-18 13:06:02 +09:00
ok ( sim . includes ( "spawnRequested" ) && sim . includes ( "poolEligible" ) && sim . includes ( "pooled" ) , "effect runtime diagnostics expose spawn and pool counters" ) ;
2026-07-18 22:15:26 +09:00
const direct = [ ... all . matchAll ( /(?:effects(?:\?\.)?\.push|effects\.push)\(new\s+(?:global\.)?(?:TarinaiEffect|EffectCtor|Effect)\(/g ) ] . length ;
ok ( direct === 0 , "normal Effect construction is routed through queueEffect" ) ;
2026-07-18 13:06:02 +09:00
console . log ( "[OK] effect runtime regression audit passed" ) ;