Class

RezCard

RezCard()

Constructor

# new RezCard()

Represents a card in the Rez game engine. Cards are the primary content containers that display narrative text, choices, and interactive elements to the player.

Cards exist within scenes and follow a defined lifecycle:

  1. start - Card is initialized and becomes the current card
  2. ready - Card is rendered and ready for player interaction
  3. finish - Card is being replaced or scene is ending

Template System

Cards use templates to render their content:

  • $content_template - The primary face template (required)
  • $back_template - Optional back-face template for use in stack layouts
  • current_face - The active face name (default "content")
  • faces - Set of face names declared on this card (default #{:content, :back})

Scene Relationship

Cards have a transient reference to their containing scene, set when the scene calls playCard(). In single layout mode, this reference becomes stale when the card is replaced. In stack layout mode, the reference persists while the scene is running.

Block System

Each card is wrapped in a RezBlock for rendering. The block manages the card's position in the layout and handles flip state transitions.

Event Handlers

Cards can define event handlers using the on_<event> attribute naming convention:

  • on_start - Called when the card becomes the current card
  • on_ready - Called after the card is rendered
  • on_finish - Called when the card is being replaced
  • on_<custom> - Custom events triggered by game logic

View Source rez_card.js, line 5

Extends

Methods

# bindAs() → {string}

Returns the binding identifier used in template rendering. When a card is rendered, its properties are bound to the template context under this name.

View Source rez_card.js, line 104

"card"

string

# constructor(id, attributes)

Creates a new card instance with null scene and block references

Parameters:
Name Type Description
id string

unique identifier for this card

attributes object

card attributes from Rez compilation

Overrides:

View Source rez_card.js, line 45

# current_block(block)

Sets the RezBlock instance for this card. Called by the scene when adding the card to the view layout.

Parameters:
Name Type Description
block RezBlock

the block to set

View Source rez_card.js, line 69

# getViewTemplate(faceopt) → {function}

Returns the template for the specified face. The face name maps to a compiled template attribute: face "content" → $content_template, face "back" → $back_template, etc.

Parameters:
Name Type Attributes Description
face string <optional>

the face name to get the template for. Defaults to the card's current_face attribute.

View Source rez_card.js, line 115

if the card has no template for the requested face

Error

the template function for rendering this card's current face

function

# handleCustomEvent(event_name, evt) → {object}

Handles custom events by looking up and invoking the appropriate event handler. Event handlers are defined using the on_<event_name> attribute naming convention. Returns an error object with a descriptive message if no handler is found.

Parameters:
Name Type Description
event_name string

the name of the custom event to handle

evt RezEvent

the event object containing event data

View Source rez_card.js, line 134

the result from the event handler, or an error object if no handler exists

object

# scene(scene)

Sets the scene reference for this card. Called by the scene when starting a new card.

Parameters:
Name Type Description
scene RezScene

the scene to set

View Source rez_card.js, line 93