forked from phenom/healer-man
22 lines
659 B
TypeScript
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;
|
|
};
|
|
}
|