Files
healer-man/src/game/combatClock.ts
T
2026-08-30 14:16:56 -04:00

22 lines
659 B
TypeScript

export type CombatClock = () => number;
let activeCombatClock: CombatClock = () => Date.now();
/** Shared simulation time. Production uses wall time; deterministic tools inject a fixed-step clock. */
export function combatNow(): number {
return activeCombatClock();
}
/**
* Replaces the combat clock and returns a disposer that restores the previous
* source. Benchmark callers must run sequentially because combat stores are
* process-wide singletons.
*/
export function installCombatClock(clock: CombatClock): () => void {
const previous = activeCombatClock;
activeCombatClock = clock;
return () => {
activeCombatClock = previous;
};
}