import test from "node:test"; import assert from "node:assert/strict"; import { EcsWorld } from "../src/ecs/world.js"; import { Component } from "../src/ecs/components.js"; import { stepPassiveHealthRegen } from "../src/combat/service.js"; import { markHealthDamaged, PASSIVE_HP_REGEN_DELAY_MS } from "../../shared/combat/passiveRegen.js"; test("passive health regen waits one minute after damage", () => { const ecs = new EcsWorld(); const entityId = 1; const handle = ecs.spawn(entityId); ecs.add(handle, Component.position, { tileX: 8, tileY: 8 }); ecs.add(handle, Component.health, { current: 10, max: 100 }); const world = { ecs, chunkIsSimulating: () => true }; const now = 1_000_000; markHealthDamaged(ecs.get(handle, Component.health), now); stepPassiveHealthRegen(world, now + PASSIVE_HP_REGEN_DELAY_MS - 1, 1); assert.equal(ecs.get(handle, Component.health).current, 10); const events = stepPassiveHealthRegen(world, now + PASSIVE_HP_REGEN_DELAY_MS + 10_000, 10); assert.ok(events.some((event) => event.type === "entity-health")); assert.ok(ecs.get(handle, Component.health).current > 10); });