"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"); ok(combat.includes('"bleed", "bubble", "eat", "explosion", "heart", "shoot_impact", "zunchi_miasma", "electric_shock", "wind"'), "all transient effect variants use the reusable pool path"); ok(combat.includes("offscreenCulled"), "low-importance offscreen spawns are tracked and culled"); 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"); ok(sim.includes('if (effect.type === "ring")') && sim.includes("lightweight"), "rings bypass the budgeted physics update path"); ok(!sim.includes("const budgeted = []"), "effect updates do not allocate a temporary active-effect array each frame"); ok(sim.includes("spawnRequested") && sim.includes("poolEligible") && sim.includes("pooled"), "effect runtime diagnostics expose spawn and pool counters"); 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"); console.log("[OK] effect runtime regression audit passed");