Class: RezGame

RezGame(id, attributes)

new RezGame(id, attributes)

Represents the singleton @game instance
Parameters:
Name Type Description
id string
attributes object
Source:

Members

(static) undoManager

Properties:
Name Type Description
undoManager RezUndoManager the game undo manager
Source:

Methods

addToAttrIndex(elem)

For each attribute defined on this game object, add it to the game-wide index for that attribute.
Parameters:
Name Type Description
elem basic_object element whose attributes are to be indexed
Source:

getObjectsWith(attr_name) → {Array}

Return the ids of all game elements having the specified attribute.
Parameters:
Name Type Description
attr_name string
Source:
Returns:
matching element ids
Type
Array

indexAttribute(elem_id, attr_name)

Adds the element to the per-attribute index.
Parameters:
Name Type Description
elem_id string id of element to add to the per-attr index
attr_name string
Source:

(static) addFlashMessage(message)

adds the given message to the flash to be displayed on the next render
Parameters:
Name Type Description
message string
Source:

(static) addGameObject(obj)

adds an object representing a game element to the game world and automatically tagging it by its attributes
Parameters:
Name Type Description
obj object game-object
Source:

(static) addToTagIndex(obj)

indexes the specified game-object for all tags in it's tags attribute
Parameters:
Name Type Description
obj object game-object
Source:

(static) archive() → {string}

Source:
Returns:
JSON formatted archive string
Type
string

(static) bindAs() → {string}

Source:
Returns:
default binding name for this object
Type
string

(static) canResume() → {boolean}

returns true if there is at least one scene in the scene stack
Source:
Returns:
Type
boolean

(static) clearFlashMessages()

empties the flash messages
Source:

(static) dataWithArchivedObjects(data) → {object}

Parameters:
Name Type Description
data object data archive to append objects to
Source:
Returns:
modified data archive
Type
object

(static) elementAttributeHasChanged(elem, attr_name, old_value, new_value)

should be called whenever an attribute value is changed Currently this function notifies the undo manager and the view
Parameters:
Name Type Description
elem object reference to game-object
attr_name string name of the attribute whose value has changed
old_value * value of the attribute before the change
new_value * value of the attribute after the change
Source:

(static) filterObjects(pred) → {array}

filters all game-objects returning those for which the pred filter returns true
Parameters:
Name Type Description
pred function predicate to filter with
Source:
Returns:
game-objects passing the filter
Type
array

(static) getAll(target_type) → {array}

filters all game-objects returning those with the specified type
Parameters:
Name Type Description
target_type string (optional) a specific game object type (e.g. 'actor', 'item')
Source:
Returns:
game-objects with the specified type
Type
array

(static) getEnabledSystems() → {array}

Source:
Returns:
all 'system' game-objects with attribute enabled=true
Type
array

(static) getGameObject(id, should_throw) → {basic_object|null}

given an element id returns the appropriate game-object reference If should_throw is true an exception will be thrown if the element id is not valid. Otherwise null is returned.
Parameters:
Name Type Description
id string id of game-object
should_throw boolean (default: true)
Source:
Returns:
game-object or null
Type
basic_object | null

(static) getRelationship(source_id, target_id) → {RezRelationship|null}

we can cheat looking up a relationship because we know how their IDs are constructed. Note that in Rez relationships are unidirectional so that getRelationship("a", "b") and getRelationship("b", "a") are different RezRelationship objects.
Parameters:
Name Type Description
source_id string id of game-object that holds the relationship
target_id string id of game-object to which the relationship refers
Source:
Returns:
the relationship object for this relationship
Type
RezRelationship | null

(static) getTaggedWith(tag) → {array}

returns all game-objects tagged with the specified tag
Parameters:
Name Type Description
tag string
Source:
Returns:
array of indexed game-objects that have the specified tag
Type
array

(static) getTarget(target_id) → {object}

it looks like this was a holdover from when we didn't add the game object to itself under the "game" id.
Parameters:
Name Type Description
target_id string
Deprecated:
  • Yes
Source:
Returns:
Type
object

(static) getTypedGameObject(id, type, should_throw) → {basic_object|null}

Parameters:
Name Type Description
id string id of game-object
type string game object type (e.g. 'actor' or 'item')
should_throw boolean (default: true)
Source:
Returns:
game-object or null
Type
basic_object | null

(static) getViewTemplate() → {*}

Source:
Returns:
the layout template object, need to check what type that is
Type
*

(static) indexObjectForTag(obj, tag)

applies the specified tag to the spectified game-object
Parameters:
Name Type Description
obj object reference to a game-object
tag string
Source:

(static) initLevels() → {Array}

Source:
Returns:
array of init levels to run (e.g. [0, 1, ..])
Type
Array

(static) interludeSceneWithId(scene_id, params)

interrupts the current scene, pushing it to the scene stack, and then starts the new scene with the given id
Parameters:
Name Type Description
scene_id string
params object data to pass to the new scene
Source:

(static) load(source)

given a JSON source archive restore the game state to what was archived.
Parameters:
Name Type Description
source string JSON format source archive
Source:

(static) popScene(params)

removes the top object of the scene stack and makes it the current scene
Parameters:
Name Type Description
params object data to be passed to the scene being resumed
Source:

(static) pushScene()

interrupts the current scene and puts it on the scene stack
Source:

(static) removeFromTagIndex(obj)

unindexes the specified object from all tags in its tags attribute
Parameters:
Name Type Description
obj object game-object
Source:

(static) resumePrevScene(params)

finishes the current scene, then pops the previous scene from the scene stack and resumes it
Parameters:
Name Type Description
params object data to pass back to the previous scene
Source:

(static) save()

triggers a download of the game archive This uses a hidden link with a 'download' attribute. The link is "clicked" triggering the download of the JSON file. A timeout is used to remove the link.
Source:

(static) saveFileName(prefix) → {string}

generates a save file name using a prefix & a date-time with a .json extension.
Parameters:
Name Type Description
prefix string (defaults to game name)
Source:
Returns:
file name
Type
string

(static) setViewContent(content)

Informs the view of new content to be rendered. It is left up to the view & its layout to determine how this affects any existing content of the view.
Parameters:
Name Type Description
content Object block to be added to the view
Source:

(static) setViewLayout(layout)

???
Parameters:
Name Type Description
layout * ???
Source:

(static) start(container_id)

called automatically from the index.html this runs init on the registered game objects then starts the view and starts the initial scene
Parameters:
Name Type Description
container_id string id of the HTML element into which game content is rendered
Source:

(static) startSceneWithId(scene_id, params)

finish the current scene and start the new scene with the given id
Parameters:
Name Type Description
scene_id string id of scene game-object
params object data to pass to the new scene
Source:

(static) toJSON() → {object}

Source:
Returns:
a versioned JSON archive
Type
object

(static) unindexObjectForTag(obj, tag)

removes the specified tag from the specified game-object
Parameters:
Name Type Description
obj object reference to a game-object
tag string a tag to remove
Source:

(static) updateView()

re-renders the view calling the 'before_render' and 'after_render' game event handlers
Source: