Class

RezEventProcessor

RezEventProcessor()

Constructor

# new RezEventProcessor()

Processes events in the Rez game engine. Handles browser events (clicks, inputs, submits), custom game events, timer events, and system events. Routes events to appropriate handlers and manages the event lifecycle including system pre/post processing and undo manager integration.

View Source rez_event.js, line 713

Methods

# afterEventProcessing(evt, result) → {*}

Runs the event result through all enabled systems' after_event handlers. Each system can modify the result after the event has been processed.

Parameters:
Name Type Description
evt Event

the original browser event

result *

the result from event processing

View Source rez_event.js, line 912

if any system handler doesn't return a valid result object

Error

the processed result

*

# beforeEventProcessing(evt) → {Event}

Runs the event through all enabled systems' before_event handlers. Each system can modify the event before it gets processed.

Parameters:
Name Type Description
evt Event

the browser event to pre-process

View Source rez_event.js, line 890

if any system handler doesn't return a valid event object

Error

the processed event

Event

# busy() → {boolean}

When busy, player-initiated events are ignored to stop the player from interfering with a queued sequence (e.g. a monster taking several actions).

View Source rez_event.js, line 822

true while one or more locking queued sequences are in flight

boolean

# card() → {RezCard}

View Source rez_event.js, line 753

the current card

RezCard

# constructor(game)

Creates a new event processor for the specified game

Parameters:
Name Type Description
game RezGame

the game instance this processor belongs to

View Source rez_event.js, line 724

# decodeEvent(evt) → {Array}

Extracts event name, target, and parameters from an element's dataset attributes

Parameters:
Name Type Description
evt Event

the browser event to decode

View Source rez_event.js, line 1045

[eventName, target, params] decoded from the event's dataset

Array

# decrementPending()

Decrements the busy counter; on returning to 0 clears the busy cue.

View Source rez_event.js, line 877

# dispatchResponse(response)

Processes a RezEvent response by executing the actions it specifies: flash messages, scene changes/interludes/resumes, card plays, view renders, and error handling.

Parameters:
Name Type Description
response RezEvent

the event response to process

View Source rez_event.js, line 762

if the response is not a RezEvent instance

Error

# game() → {RezGame}

View Source rez_event.js, line 735

the game instance

RezGame

# getEventHandler(eventName) → {Array}

Finds an event handler by checking card, scene, and game in that order. Returns the first receiver that has a handler for the event.

Parameters:
Name Type Description
eventName string

the name of the event to find a handler for

View Source rez_event.js, line 1169

[receiver, handler] pair where receiver is the object that handles the event

Array

# getReceiverEventHandler(receiver, eventname) → {function|null}

Gets an event handler function from a receiver object

Parameters:
Name Type Description
receiver *

the object to check for event handlers

eventname string

the name of the event to find a handler for

View Source rez_event.js, line 1152

the event handler function or null if not found

function | null

# handleBrowserClickEvent(evt) → {*}

Handles browser click events by decoding the event data and routing to appropriate handlers. Supports built-in event types (card, switch, interlude, resume) and custom events.

Custom events receive the native click MouseEvent as params.evt, giving on_<event> handlers access to shiftKey, ctrlKey, altKey, metaKey and other native event properties for modifier-aware behaviour (e.g. shift-click). evt is therefore a reserved param name and will shadow any data-evt attribute.

Parameters:
Name Type Description
evt Event

the click event

View Source rez_event.js, line 1116

the result of handling the click event

*

# handleBrowserEvent(evt) → {*}

Main event handler that processes browser events. Handles undo recording, system pre/post processing, and routes events to specific handlers based on type.

Parameters:
Name Type Description
evt Event

the browser event to handle

View Source rez_event.js, line 997

the result of processing the event

*

# handleBrowserInputEvent(evt) → {RezEvent}

Handles browser input events by finding the card that contains the input element and calling its input event handler.

Parameters:
Name Type Description
evt Event

the input event

View Source rez_event.js, line 1269

if the card container or card ID cannot be found

Error

the result of the card's input event handler

RezEvent

# handleBrowserSubmitEvent(evt) → {RezEvent}

Handles browser form submit events by finding the card that contains the form and calling its event handler named after the form.

Parameters:
Name Type Description
evt Event

the submit event

View Source rez_event.js, line 1300

if the form name or card container cannot be found

Error

the result of the card's form event handler

RezEvent

# handleCardEvent(target, params) → {RezEvent}

Handles built-in card events that play a specific card

Parameters:
Name Type Description
target string

ID of the card to play

params object

parameters to pass to the card

View Source rez_event.js, line 1209

event that plays the specified card

RezEvent

# handleCustomEvent(eventName, params) → {RezEvent}

Handles custom events by finding and calling the appropriate event handler

Parameters:
Name Type Description
eventName string

the name of the custom event

params object

parameters to pass to the event handler

View Source rez_event.js, line 1189

the result of the event handler or an error event

RezEvent

# handleInterludeEvent(target, params) → {RezEvent}

Handles built-in interlude events that interrupt the current scene

Parameters:
Name Type Description
target string

ID of the scene to interlude with

params object

parameters to pass to the scene

View Source rez_event.js, line 1239

event that starts an interlude with the specified scene

RezEvent

# handleKeyBindingEvent(evt) → {*}

Handles key binding events by routing them to custom event handlers

Parameters:
Name Type Description
evt CustomEvent

the key binding event with event name details

View Source rez_event.js, line 1077

the result of handling the key binding event

*

# handleResumeEvent(params) → {RezEvent}

Handles built-in resume events that return to the previous scene

Parameters:
Name Type Description
params object

parameters to pass to the resumed scene

View Source rez_event.js, line 1254

event that resumes the previous scene

RezEvent

# handleSwitchEvent(target, params) → {RezEvent}

Handles built-in switch events that change to a new scene

Parameters:
Name Type Description
target string

ID of the scene to switch to

params object

parameters to pass to the scene

View Source rez_event.js, line 1224

event that changes to the specified scene

RezEvent

# handleTimerEvent(evt) → {*}

Handles timer events by routing them to custom event handlers

Parameters:
Name Type Description
evt CustomEvent

the timer event with timer details

View Source rez_event.js, line 1060

the result of handling the timer event

*

# handleWindowEvent(evt) → {*}

Handles window events by routing them to custom event handlers with the "window_" prefix (e.g. "wheel" becomes "window_wheel")

Parameters:
Name Type Description
evt CustomEvent

the window event with event name and browser event details

View Source rez_event.js, line 1093

the result of handling the window event

*

# incrementPending()

Increments the busy counter; on the 0->1 transition raises the busy cue.

View Source rez_event.js, line 865

# isAutoUndoEvent(evt) → {boolean}

Determines if an event should automatically record undo state

Parameters:
Name Type Description
evt Event

the event to check

View Source rez_event.js, line 972

true if this event type should trigger automatic undo recording

boolean

# isPlayerInitiatedEvent(evt) → {boolean}

Player-initiated events (clicks, input, form submits, key bindings) are gated while the processor is busy running a queued sequence. Timer, window, and internally-raised queued events are not player-initiated and are never gated.

Parameters:
Name Type Description
evt Event

the event to check

View Source rez_event.js, line 983

true if this event was directly initiated by the player

boolean

# raiseKeyBindingEvent(event_name) → {*}

Creates and processes a custom key binding event

Parameters:
Name Type Description
event_name string

the name of the key binding event

View Source rez_event.js, line 947

the result of processing the key binding event

*

# raiseTimerEvent(timer) → {*}

Creates and processes a custom timer event

Parameters:
Name Type Description
timer RezTimer

the timer that fired

View Source rez_event.js, line 935

the result of processing the timer event

*

# raiseWindowEvent(eventName, browserEvt) → {*}

Creates and processes a custom window event that wraps a native browser event

Parameters:
Name Type Description
eventName string

the name of the window event (e.g. "wheel", "resize")

browserEvt Event

the native browser event

View Source rez_event.js, line 959

the result of processing the window event

*

# scene() → {RezScene}

View Source rez_event.js, line 744

the current scene

RezScene

# scheduleQueuedEvent(queued)

Schedules a queued event to fire after its delay. The handler is invoked directly via handleCustomEvent (not handleBrowserEvent), so queued events deliberately bypass system before_event/after_event processing and undo recording — they are treated as internal, not player-initiated. Its response is fully dispatched (so it may itself queue further events, forming a chain). A locking queued event increments the busy counter immediately (holding the input gate across the delay) and releases it only after its response has been dispatched. Because a chained next-step is scheduled inside dispatchResponse (re-incrementing) before the release runs, the counter never reaches 0 mid-chain, so the gate stays continuous for the whole sequence.

Parameters:
Name Type Description
queued object

descriptor {eventName, params, target, delay, lock}

View Source rez_event.js, line 833