The pack
encounterDirector
function encounterDirector(): Pack<{ encounterDirector: EncounterDirectorApi }>
The encounter-director pack: game.encounterDirector. No options.
Helpers
createEncounter
function createEncounter(plan: EncounterPlan): EncounterDirector
Play a plan. Throws, with every fault, on a plan validateEncounter refuses.
encounterKinds
const encounterKinds: HazardKind[]
The built-in hazard kinds.
encounterPhases
const encounterPhases: EncounterPhase[]
The built-in phases.
generateEncounter
function generateEncounter(options: EncounterOptions = {}): EncounterPlan
Generate a plan. Throws, with every fault, when the options cannot make a fair one.
validateEncounter
function validateEncounter(plan: EncounterPlan): string[]
Check a plan: timing, lanes, a safe lane at every moment, the budget, and time to reach safety. Empty when fair.
Types
EncounterDirector
interface EncounterDirector
A plan being played.
readonly plan: EncounterPlan— The plan.readonly time: number— Seconds played.readonly done: boolean— True once the plan has run out.readonly phase: string— The phase now.tick(dt: number): void— Advancedtseconds.hazards(): (HazardCue & { active: boolean; left: number })[]— The hazards warning or live now, withactivetrue for the live ones andleftthe seconds to the next change.safeLanes(): number[]— The lanes no live hazard covers.live(lane: number): boolean— True when a lane is covered by a live hazard.drain(): EncounterEvent[]— Events since the last call.snapshot(): { time: number }— The time, as plain JSON, to restore.restore(save: { time: number }): void— Go back (or on) to a saved time.
EncounterDirectorApi
interface EncounterDirectorApi
What the encounter-director pack adds to a game: game.encounterDirector.
create: typeof createEncounter— Play a plan.generate: typeof generateEncounter— Generate a fair plan by seed.validate: typeof validateEncounter— Check a plan.kinds: typeof encounterKinds— The built-in hazard kinds.phases: typeof encounterPhases— The built-in phases.
EncounterEvent
type EncounterEvent = | { kind: 'warning' | 'active' | 'ended'; id: string; time: number } | { kind: 'phase'; name: string; time: number } | { kind: 'complete'; time: number }
Something the director says.
EncounterOptions
interface EncounterOptions
What an encounter is generated from.
seed?: number— The seed. Default 1.lanes?: EncounterRange— How many lanes. Default[5, 7].duration?: number— Its length in seconds. Default 40.budget?: number— The most cost live at once. Default 3.warning?: number— The least warning, in seconds. Default 1.6.laneTime?: number— Seconds to cross one lane: warnings stretch so the furthest lane can reach a safe one. Default 0.7.gap?: number— Seconds of calm after a hazard before the next, at no pressure. Default 1.6.kinds?: HazardKind[]— The hazard kinds. DefaultencounterKinds.phases?: EncounterPhase[]— The phases. Default probe, pressure and finale.intensity?: number— Raises every phase's pressure: 0 as written, 1 as hard as it goes. Default 0.
EncounterPhase
interface EncounterPhase
A stretch of the encounter.
name: string— Its name.at: number— Where it starts, as a fraction of the encounter.pressure: number— How hard it presses, 0 to 1: how many lanes a hazard takes, how close hazards follow, whether they overlap.
EncounterPlan
interface EncounterPlan
A plan: what the director plays.
seed: number— The seed the plan was generated from; 1 for the default.lanes: number— How many lanes the encounter has, a whole number from 2 to 100; cues name lanes 0 tolanes - 1.budget: number— The most cost that may be live at once.minWarning: number— The least warning a cue may have.secondsPerLane: number— Seconds to cross a lane.duration: number— Seconds.phases: { at: number; name: string }[]— Phases by start time in seconds.cues: HazardCue[]— Every hazard in the encounter.
EncounterRange
type EncounterRange = number | [number, number]
A number, or [min, max] picked by seed.
HazardCue
interface HazardCue
One hazard in a plan.
id: string— Its unique name within the plan, such as'cue-0'; events refer to the cue by it.kind: string— Its kind's name.at: number— When its warning starts, seconds into the encounter.warning: number— Seconds of warning.duration: number— Seconds live after it.lanes: number[]— The lanes it hits.cost: number— Its cost against the budget.
HazardKind
interface HazardKind
A kind of hazard.
id: string— Its name:'beam','pulse', a game's own.cost?: number— What it costs against the budget while it is live. Default 1.duration?: EncounterRange— Seconds it is live. Default[0.65, 1.3].shape?: 'block' | 'scatter' | 'alternate'— How the lanes it hits lie: side by side ('block'), anywhere ('scatter'), or every other ('alternate'). Default'scatter'.weight?: number— How common against the other kinds. Default 1.


