15 lines
650 B
TypeScript
15 lines
650 B
TypeScript
import type { HeatStrike, NightState } from '../data/types';
|
|
|
|
/** CONTRACTS.md §3: heatStrikes is "run-scoped, max 3". Design §2: 3 = licence gone. */
|
|
export const MAX_HEAT_STRIKES = 3;
|
|
|
|
/**
|
|
* Whether a strike is worth recording. Two guards, both contract-driven:
|
|
* past three the run is already over, and a breach that persists (over capacity
|
|
* for an hour) is ONE offence the inspector writes up, not one per patron.
|
|
*/
|
|
export function shouldRecordStrike(state: NightState, strike: HeatStrike): boolean {
|
|
if (state.heatStrikes.length >= MAX_HEAT_STRIKES) return false;
|
|
return !state.heatStrikes.some((s) => s.reason === strike.reason);
|
|
}
|