// Floor hazards & duties (docs/SCENARIOS.md): the vomit protocol, water-station
// RSA and the fainter. Pure numbers here, tested; the scene supplies rng rolls
// and sprites. Same split as glassie.ts.

/** How close an agent must wander to an unsigned puddle to be at risk. */
export const SLIP_RADIUS_PX = 20;
/** Per-second chance an at-risk agent goes over. */
export const SLIP_CHANCE_PER_S = 0.2;
/** One slip per patron per this window — nobody slips twice in one stride. */
export const SLIP_COOLDOWN_MS = 2600;
/** Mopping is a commitment: feet planted, this long. */
export const MOP_MS = 2200;
/** The floor can only be so decorated: active puddles and per-night events. */
export const MAX_PUDDLES = 2;
export const MAX_VOMITS_PER_NIGHT = 3;
/** Per-second chance a messy/maggot patron redecorates (very small; there are
 * many drunk-seconds in a night). */
export const VOMIT_CHANCE_PER_S = 0.0025;

/**
 * Chance of a slip in a tick of `dtMs`, for an agent inside the radius of an
 * UNSIGNED puddle. Signed puddles never slip anyone — that is what the sign is.
 */
export function slipChance(signed: boolean, dtMs: number): number {
  if (signed) return 0;
  return Math.min(1, (dtMs / 1000) * SLIP_CHANCE_PER_S);
}

// ---- water station (RSA) ----------------------------------------------------

/** What one cup of water takes off. Real, but not a cure — a maggot stays a
 * problem; a 'loose' catch early is the whole point of the duty. */
export const WATER_SOBER_STEP = 0.07;

export function watered(intoxication: number): number {
  return Math.max(0, intoxication - WATER_SOBER_STEP);
}

// ---- the fainter -------------------------------------------------------------

/** The QTE, deliberately plain: three steps, generous windows, no jokes. */
export interface AidStep {
  key: string;
  label: string;
  ms: number;
}

export const AID_STEPS: readonly AidStep[] = [
  { key: 'SPACE', label: 'clear a space around them', ms: 5000 },
  { key: 'B', label: 'check they are breathing', ms: 5000 },
  { key: 'R', label: 'roll them onto their side', ms: 5000 },
];

/** Unattended this long, it stops being your call — the ambulance is called. */
export const FAINT_UNATTENDED_MS = 100_000;

/** Chance a night has a fainter at all, and the clock window it lands in. */
export const FAINT_NIGHT_CHANCE = 0.55;
export const FAINT_WINDOW: readonly [number, number] = [150, 330];
