Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Asset

Extends: adventurejs.Atom

Defined in: adventure/Asset.js, line 5

How to: How to: Assets

Public Constructor:

MyGame.createAsset({ "class":"Asset", "name":"foo" })

Asset is subclassed from the foundational class Atom, and is the most basic game world class from which all other asset classes, Tangible, Substance, and Intangible, are derived. Besides setting the prototypal validation and initialization functions, it also defines many common properties used to determine how assets appear in printed statements. It's unlikely that authors would want to subclass Asset directly as it has few properties, unless it's to create a whole new low-level Asset type.

Private Constructor:

var foo = new adventurejs.Asset(game_name, name)

Though all in-game glasses use a standard constructor method under the hood, it's unlikely that you'd need to call it directly. To create an instance of the Asset class, it must be defined in a game file as a generic object. That object will be used at runtime to construct a new game class instance, which will be validated and initialized before adding it to the Game. See above for the public constructor, or see Game#createAsset to learn more.

Parameters:

  • game_name String
    The name of the top level game object.
  • name String
    A name for the object, to be serialized and used as ID.
Inherited Overrides
IndexMethodsProperties

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

$is()

Defined in: adventure/asset/_is.js, line 7

$is() is a generalized method for getting various asset states, usually stored in the asset.is nested object. It can also test for more complex circumstances, such as in the case of Tangibles. For example, if your game has a sword in a stone, you can test whether the sword is currently in the stone with MyGame.$("sword").is("in", "stone")
addWordsToLookup(allTheWords, typeOfWord)

Defined in: adventure/asset/addWordsToLookup.js, line 6

Parameters:

  • allTheWords Array
  • typeOfWord String
addWordsToLookup() takes words associated with this asset and adds them to the global lookup table.
aliases()

Defined in: adventure/Asset.js, line 951

aliases() is a collection of method names that are meant for authors to use. Since they don't exist on all classes, we set up these aliases so that, if authors call them on classes they're not applicable to, they will politely return null instead of throwing a "not a function" error.
canSetVerbState(verb) → {Boolean}

Defined in: adventure/asset/canSetVerbState.js, line 6

Parameters:

  • verb String
canSetVerbState is a method to check whether the specified verb can set state on this asset. Assumes that asset.is.direct_object_of_verb[verb].enabled is true

Returns:

Boolean
destroy()

Defined in: adventure/asset/destroy.js, line 7

Todos: What else needs to happen on destroy?

destroy is called to remove an asset from the game world.
didDoVerbs(verbs) → {Boolean}

Defined in: adventure/asset/didDoVerbs.js, line 6

Parameters:

  • verbs Array
didDoVerbs check whether any of the specified verbs has ever been applied to the asset as a direct object. This is a convenience method that relies on asset.DOVdidDo()

Returns:

Boolean
didIoVerbs(verbs) → {Boolean}

Defined in: adventure/asset/didIoVerbs.js, line 6

Parameters:

  • verbs Array
didIoVerbs check whether any of the specified verbs has ever been applied to the asset as an indirect object. This is a convenience method that relies on asset.IOVdidDo()

Returns:

Boolean
DOVallowOnce(verb) → {Boolean}

Defined in: adventure/asset/DOVallowOnce.js, line 6

Parameters:

  • verb String
DOVallowOnce is a method to check whether this asset is subscribed to allow the specified verb to act on it as a direct object only once.

Returns:

Boolean
DOVallowWithAnything(verb) → {Boolean}

Defined in: adventure/asset/DOVallowWithAnything.js, line 6

Parameters:

  • verb String
DOVallowWithAnything is a method to check whether this asset is subscribed to act as a direct object with the specified verb without any direct object.

Returns:

Boolean
DOVallowWithAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/DOVallowWithAsset.js, line 6

Parameters:

  • verb String
  • asset Object
DOVallowWithAsset is a method to check whether this asset is subscribed to act as a direct object with the specified verb and indirect object.

Returns:

Boolean
DOVallowWithNothing(verb) → {Boolean}

Defined in: adventure/asset/DOVallowWithNothing.js, line 6

Parameters:

  • verb String
DOVallowWithNothing is a method to check whether this asset is subscribed to act as a direct object with the specified verb without any indirect object. For example, "plug in computer" where when an outlet is implied but not defined.

Returns:

Boolean
DOVdidDo(verb) → {Boolean}

Defined in: adventure/asset/DOVdidDo.js, line 6

Parameters:

  • verb String
DOVdidDo is a method to check whether this asset was already used as a direct objecb by the specified verb.

_didDo is an alias meant for authors.

Returns:

Boolean
DOVdidDoCount(verb) → {Int}

Defined in: adventure/asset/DOVdidDoCount.js, line 6

Parameters:

  • verb String
DOVdidDoCount is a method to get a count of times this asset was used as a direct object by the specified verb.

_doCount is an alias meant for authors.

Returns:

Int
DOVdidTry(verb) → {Boolean}

Defined in: adventure/asset/DOVdidTry.js, line 6

Parameters:

  • verb String
DOVdidTry is a method to check whether it was attempted to use this asset as a direct object by the specified verb.

_didTry is an alias meant for authors.

Returns:

Boolean
DOVdidTryCount(verb) → {Boolean}

Defined in: adventure/asset/DOVdidTryCount.js, line 6

Parameters:

  • verb String
DOVdidTryCount is a method to get a count of times it was tried to use this asset as a direct object by the specified verb.

_tryCount is an alias meant for authors.

Returns:

Boolean
DOVgetConnectionCount(verb) → {Int}

Defined in: adventure/asset/DOVgetConnectionCount.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.direct_object_of_verb[verb].with_params.connections.length

Returns:

Int
DOVgetConnections(verb) → {Array}

Defined in: adventure/asset/DOVgetConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.direct_object_of_verb[verb].with_params.connections

Returns:

Array
DOVgetMaxConnections(verb) → {Int}

Defined in: adventure/asset/DOVgetMaxConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.direct_object_of_verb[verb].with_params.max_connections

Returns:

Int
DOVhasIndirectObjects(verb) → {Boolean}

Defined in: adventure/asset/DOVhasIndirectObjects.js, line 6

Parameters:

  • verb String
DOVhasIndirectObjects is a method to check whether this asset has any particular indirect objects specified by the author for use with the specified verb.

Returns:

Boolean
DOVhasMaxConnections(verb) → {Boolean}

Defined in: adventure/asset/DOVhasMaxConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Get whether the DOV has maximum connections.

Returns:

Boolean
DOVincrementDoCount(verb)

Defined in: adventure/asset/DOVincrementDoCount.js, line 6

Parameters:

  • verb String
DOVincrementDoCount is a method to increment the number of times the specified verb has acted on this asset as a direct object.
DOVincrementTryCount(verb)

Defined in: adventure/asset/DOVincrementTryCount.js, line 6

Parameters:

  • verb String
DOVincrementTryCount is a method to increment the number of times the specified verb has been tried on this asset as a direct object.
DOVisConnectedToAnything(verb) → {Boolean}

Defined in: adventure/asset/DOVisConnectedToAnything.js, line 6

Parameters:

  • verb String
    The name of a verb.
Check whether this asset is currently connected to anything directly by a verb such as plugIn or tie. For example, if this asset is a computer plugged into an outlet, this method would return true.

Returns:

Boolean
DOVisConnectedToAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/DOVisConnectedToAsset.js, line 6

Parameters:

  • verb String
    The name of the verb to test.
  • asset Object | String
    A game asset or asset id to test.
Check whether this asset is currently connected as a direct object to the specified indirect object by the specified verb. For example, in the case of a computer plugged into an outlet, the computer would be the direct object, and calling this method on it would return true.

Returns:

Boolean
DOVisConnectedToNothing(verb) → {Boolean}

Defined in: adventure/asset/DOVisConnectedToNothing.js, line 6

Parameters:

  • verb String
    The name of a verb.
Check whether this asset is currently connected as an indirect object to nothing by the specified verb. For example, in the case of a computer that can be plugged in, an author might prefer not to create a specific outlet into which to plug the computer. For that case we allow 'plug in computer', and store a null value to asset.is.direct_object_of_verb.plugIn.with_params.connections to represent the computer's plugged in state.

Returns:

Boolean
DOVsetConnection(verb, asset)

Defined in: adventure/asset/DOVsetConnection.js, line 6

Parameters:

  • verb String
  • asset Object
Set asset's direct verb param connection to specified indirect object.
DOVsetWithAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/DOVsetWithAsset.js, line 6

Parameters:

  • verb String
  • asset Object
DOVsetWithAsset is used to specify another asset that can be used as an indirect object with this asset as direct object. For example, if this asset is a locking chest, chest.DOVsetWithAsset('unlock', 'gold key') would add the gold key as an indirect object of the chest.

Returns:

Boolean
DOVsetWithClass(verb, clas) → {Boolean}

Defined in: adventure/asset/DOVsetWithClass.js, line 6

Parameters:

  • verb String
  • clas String
DOVsetWithClass is a method to add an indirect object class to asset.is.direct_object_of_verb[verb].with_classes.

Returns:

Boolean
DOVunsetConnection(verb, asset)

Defined in: adventure/asset/DOVunsetConnection.js, line 6

Parameters:

  • verb String
  • asset Object
Unset asset's direct verb param connection to specified indirect object.
getDescription(description) → {String}

Defined in: adventure/asset/getDescription.js, line 6

Parameters:

  • description String
Get a description, such as "look in book", where "in" has been defined as a key at asset.descriptions.in. "look" is always the default description.

Returns:

String
getDescription(description) → {String}

Defined in: adventure/assets/tangibles/Exit.js, line 951

Parameters:

  • description String
Get a description, such as "look in book", where "in" has been defined as a key at asset.descriptions.in. "look" is always the default description. This is modified from asset.getDescription to allow exit descriptions to be stored on their apertures.

Returns:

String
getIndirectDescription(indirect_aspect, indirect_asset, direct_aspect) → {String}

Defined in: adventure/asset/getIndirectDescription.js, line 6

Parameters:

  • indirect_aspect String
  • indirect_asset Object
  • direct_aspect String
Get indirect description, such as "look at this through magnifying glass", where "through magnifying glass" is a key at asset.descriptions["through magnifying glass"].description "look" is always the default direct object description.

Returns:

String
getInheritance() → {Array}

Defined in: adventure/Atom.js, line 238

Inherited from: adventurejs.Atom#getInheritance

getInheritance is a utility method to get an asset's inheritance chain. Returns a list of class names from high to low.

Returns:

Array
getProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 184

Inherited from: adventurejs.Atom#getProperty

Parameters:

  • prop String
    Name of the property to test for. Can include dot notation.
A method to get a deep property without throwing an error. Allows for getting deep properties, ie "foo.bar.baz". Returns false if property doesn't exist, so beware of if(false === foo.bar.baz) comparisons.

Returns:

Boolean
has()

Defined in: adventure/asset/_has.js, line 7

has is an alias to asset.isIn() that reverses the direct and indirect objects, to test whether that asset is in this asset.
if( MyGame.$('crown').$has('jewel') ){ // do stuff }
hasClass(prop) → {Boolean}

Defined in: adventure/Atom.js, line 216

Inherited from: adventurejs.Atom#hasClass

Parameters:

  • prop String
    Name of the classe to test for.
A method to test whether the Atom is an instance of a given class.

Returns:

Boolean
hasDescription(description) → {String|Boolean}

Defined in: adventure/asset/hasDescription.js, line 6

Parameters:

  • description String
See if asset has a description for an aspect, such as "look in book", where "in" has been defined as a key at asset.descriptions.in. "look" is always the default description.

Returns:

String | Boolean
hasEventHook(hook, asset_name) → {Boolean}

Defined in: adventure/asset/hasEventHook.js, line 6

Parameters:

  • hook string
  • asset_name string
    We use asset.name here instead of asset.id to make life slightly easier for authors. Asset IDs are formed from asset names, but generally we don't expect authors to be aware of IDs. Hooks will only be defined by authors, so let them use asset.name as their identifier. We do however make an effort to see if an id has been passed instead of a name.
Check if this asset has an event_hooks for a given verb; additionally check if the asset has an event_hooks for a specific asset in combination with the verb. This check is also performed redundantly too in tryEventHook.js.

Returns:

Boolean
hasIndirectDescription(indirect_aspect, indirect_asset, direct_aspect) → {String|Boolean}

Defined in: adventure/asset/hasIndirectDescription.js, line 6

Parameters:

  • indirect_aspect String
  • indirect_asset Object
  • direct_aspect String
Determine whether asset has an indirect description, such as "look at this through magnifying glass", where "through magnifying glass" becomes a key at asset.descriptions["through magnifying glass"]. "look" is always the default direct object description.

Returns:

String | Boolean
hasProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 148

Inherited from: adventurejs.Atom#hasProperty

Parameters:

  • prop String
    Name of the property to test for. Can include dot notation.
A method to test whether the Atom has a given property. Allows for testing deep properties, ie "foo.bar.baz". For stupid and unaccountable reasons Ivan has decided to code adventurejs entirely in Javascript ES5, so we don't have the nicety of optional chaining introduced in ES6. This method fills in for optional chaining until we someday upgrade to ES6.

Returns:

Boolean
incrementDoVerbCount(verb, index)

Defined in: adventure/asset/incrementDoVerbCount.js, line 6

Parameters:

  • verb String
  • index Int
incrementDoVerbCount takes a verb and an index and updates this asset's count of the number of times the verb has acted upon it.
incrementTryVerbCount(verb, index)

Defined in: adventure/asset/incrementTryVerbCount.js, line 6

Parameters:

  • verb String
  • index Int
incrementTryVerbCount takes a verb and an index and updates this asset's count of the number of times the verb has attempted upon it.
initialize()

Defined in: adventure/Asset.js, line 775

initialize() is the final step of creating a new game world asset, following construction and validation. The chief job of initialization is to add all of this asset's words to MyGame.world_lookup.

Because we're not doing natural language processing and everything is indexed, we want to increase the chances that the parser understands player input that is partial or has words jumbled. We add a lookup entry for every combination of an object's adjectives with its noun(s). For example we have a "green colored pencil", and we want the parser to understand "green pencil" or "colored pencil". If there are other colored pencils, we want the parser to understand "colored pencils". If there are colored pencils in three shades of green, we want the parser to understand "green pencils". We store all of these combinations to the lookup.
IOVallowOnce(verb) → {Boolean}

Defined in: adventure/asset/IOVallowOnce.js, line 6

Parameters:

  • verb String
IOVallowOnce is a method to check whether this asset is subscribed to allow the specified verb to act on it as an indirect object only once.

Returns:

Boolean
IOVallowWithAnything(verb) → {Boolean}

Defined in: adventure/asset/IOVallowWithAnything.js, line 6

Parameters:

  • verb String
IOVallowWithAnything is a method to check whether this asset is subscribed to act as an indirect object with the specified verb and any direct object.

Returns:

Boolean
IOVallowWithAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/IOVallowWithAsset.js, line 6

Parameters:

  • verb String
  • asset Object
IOVallowWithAsset is a method to check whether this asset is subscribed to act as an indirect object with the specified verb and direct object.

Returns:

Boolean
IOVallowWithNothing(verb) → {Boolean}

Defined in: adventure/asset/IOVallowWithNothing.js, line 6

Parameters:

  • verb String
IOVallowWithNothing is a method to check whether this asset is subscribed to act as an indirect object with the specified verb without any direct object. Unlikely to happen but provided for completionism.

Returns:

Boolean
IOVdidDo(verb) → {Boolean}

Defined in: adventure/asset/IOVdidDo.js, line 6

Parameters:

  • verb String
IOVdidDo is a method to check whether this asset was already used as an indirect objecb by the specified verb.

_iDidDo is an alias meant for authors.

Returns:

Boolean
IOVdidDoCount(verb) → {Int}

Defined in: adventure/asset/IOVdidDoCount.js, line 6

Parameters:

  • verb String
IOVdidDoCount is a method to get a count of times this asset was used as an indirect object by the specified verb.

_iDoCount is an alias meant for authors.

Returns:

Int
IOVdidTry(verb) → {Boolean}

Defined in: adventure/asset/IOVdidTry.js, line 6

Parameters:

  • verb String
IOVdidTry is a method to check whether it was attempted to use this asset as an indirect object by the specified verb.

_iDidTry is an alias meant for authors.

Returns:

Boolean
IOVdidTryCount(verb) → {Boolean}

Defined in: adventure/asset/IOVdidTryCount.js, line 6

Parameters:

  • verb String
IOVdidTryCount is a method to get a count of times it was attempted to use this asset as an indirect object by the specified verb.

_iTryCount is an alias meant for authors.

Returns:

Boolean
IOVgetConnectionCount(verb) → {Int}

Defined in: adventure/asset/IOVgetConnectionCount.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.indirect_object_of_verb[verb].with_params.connections.length

Returns:

Int
IOVgetConnections(verb) → {Array}

Defined in: adventure/asset/IOVgetConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.indirect_object_of_verb[verb].with_params.connections

Returns:

Array
IOVgetMaxConnections(verb) → {Int}

Defined in: adventure/asset/IOVgetMaxConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Return this.is.indirect_object_of_verb[verb].with_params.max_connections

Returns:

Int
IOVhasDirectObjects(verb) → {Boolean}

Defined in: adventure/asset/IOVhasDirectObjects.js, line 6

Parameters:

  • verb String
IOVhasDirectObjects is a method to check whether this asset has any particular direct objects specified by the author for use with the specified verb.

Returns:

Boolean
IOVhasMaxConnections(verb) → {Boolean}

Defined in: adventure/asset/IOVhasMaxConnections.js, line 6

Parameters:

  • verb String
    The name of a verb.
Get whether the IOV has maximum connections.

Returns:

Boolean
IOVincrementDoCount(verb)

Defined in: adventure/asset/IOVincrementDoCount.js, line 6

Parameters:

  • verb String
IOVincrementDoCount is a method to increment the number of times the specified verb has acted on this asset as an indirect object.
IOVincrementTryCount(verb)

Defined in: adventure/asset/IOVincrementTryCount.js, line 6

Parameters:

  • verb String
IOVincrementTryCount is a method to increment the number of times the specified verb has been tried on this asset as an indirect object.
IOVisConnectedToAnything(verb) → {Boolean}

Defined in: adventure/asset/IOVisConnectedToAnything.js, line 6

Parameters:

  • verb String
    The name of a verb.
Check whether this asset is currently connected to anything indirectly by a verb such as plugIn or tie. For example, if this asset is an outlet with a computer plugged into it, this method would return true.

Returns:

Boolean
IOVisConnectedToAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/IOVisConnectedToAsset.js, line 6

Parameters:

  • verb String
    The name of the verb to test.
  • asset Object | String
    A game asset or asset id to test.
Check whether this asset is currently connected as an indirect object to the specified direct object by the specified verb. For example, in the case of a computer plugged into an outlet, the outlet would be the indirect object, and calling this method on it would return true.

Returns:

Boolean
IOVisConnectedToNothing(verb) → {Boolean}

Defined in: adventure/asset/IOVisConnectedToNothing.js, line 6

Parameters:

  • verb String
    The name of a verb.
Check whether this asset is currently connected as an indirect object to nothing by the specified verb. (This seems like an unlikely situation as of this writing, but is offered for completion with DOVisConnectedToNothing which does have at least one use case.)

Returns:

Boolean
IOVsetConnection(verb, asset)

Defined in: adventure/asset/IOVsetConnection.js, line 6

Parameters:

  • verb String
  • asset Object
Set asset's indirect verb param connection to specified direct object.
IOVsetWithAsset(verb, asset) → {Boolean}

Defined in: adventure/asset/IOVsetWithAsset.js, line 6

Parameters:

  • verb String
  • asset Object
IOVsetWithAsset is used to specify another asset that can be used as a direct object with this asset as indirect object. For example, if this asset is a gold key, gold_key.IOVsetWithAsset('unlock', 'chest') would add the chest as a direct object of the gold key.

Returns:

Boolean
IOVsetWithClass(verb, clas) → {Boolean}

Defined in: adventure/asset/IOVsetWithClass.js, line 6

Parameters:

  • verb String
  • clas String
IOVsetWithClass is a method to add a direct object class to asset.is.indirect_object_of_verb[verb].with_classes.

Returns:

Boolean
IOVunsetConnection(verb, asset)

Defined in: adventure/asset/IOVunsetConnection.js, line 6

Parameters:

  • verb String
  • asset Object
Unset asset's indirect verb param connection to specified direct object.
isDOV(verb) → {Boolean}

Defined in: adventure/asset/isDOV.js, line 6

Parameters:

  • verb String
isDOV is a method to check whether this asset is subscribed to allow the specified verb to act on it as a direct object.

Returns:

Boolean
isIOV(verb) → {Boolean}

Defined in: adventure/asset/isIOV.js, line 6

Parameters:

  • verb String
isIOV is a method to check whether this asset is subscribed to allow the specified verb to act on it as an indirect object.

Returns:

Boolean
isVerbState(verb) → {Boolean}

Defined in: adventure/asset/isVerbState.js, line 6

Parameters:

  • verb String
isVerbState is a method to check whether this asset already has state set by the specified verb.

Returns:

Boolean
redirectVerb(oldVerb, newVerb)

Defined in: adventure/asset/redirectVerb.js, line 7

Parameters:

  • oldVerb String
  • newVerb String
redirectVerb is a method for setting a verb redirect on this asset, such that when one verb is called on the asset, another verb will be called instead. Example: player enters "hit person", it is redirected to "slap person".
set(props) → {Object}

Defined in: adventure/Atom.js, line 134

Inherited from: adventurejs.Atom#set

Parameters:

  • props Object
    A generic object containing properties to copy to the Object instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

Object Returns the instance the method is called on (useful for chaining calls.)
setDOV(verb, params)

Defined in: adventure/asset/setDOV.js, line 7

Parameters:

  • verb String
  • params Object
setDOV is a passthrough to setVerbSubscription with direct object specified.
setDOVs(verb, params)

Defined in: adventure/asset/setDOVs.js, line 7

Parameters:

  • verb String
  • params Object
setDOVs is a passthrough to send multiple verbs to setVerbSubscription with direct object specified.
setIOV(verb, params)

Defined in: adventure/asset/setIOV.js, line 7

Parameters:

  • verb String
  • params Object
setIOV is a passthrough to setVerbSubscription with indirect object specified.
setIOVs(verb, params)

Defined in: adventure/asset/setIOVs.js, line 7

Parameters:

  • verb String
  • params Object
setIOVs is a passthrough to send multiple verbs to setVerbSubscription with indirect object specified.
setObjectOfVerbs(object_of, verb, params)

Defined in: adventure/asset/setObjectOfVerbs.js, line 7

Parameters:

  • object_of String
  • verb String
  • params Object
setObjectOfVerbs is a convenience method that passes a list of verb names through to setVerbSubscription.
setVerbSubscription(object_of, verb, params)

Defined in: adventure/asset/setVerbSubscription.js, line 6

Todos: phase out earlier version

Parameters:

  • object_of String
  • verb String | Object
    An early version takes a string, with separate params object. A later version takes an object that includes the verb name as an object key and params as value.
  • params Object
    An optional param that works with the earlier version.
setVerbSubscription is used to set individual assets' relationship to specified verbs. It's intended mostly as a private function, though it is available to authors. Each asset.can_be_[in]direct_object_of_verb.verb has the following properties and default values, copied from asset.object_of_verb;
  • name: '',
  • inherited_from: 'Asset',
  • enabled: true,
  • automatically: false,
  • automatically_after_use: false,
  • then_disable: false,
  • then_destroy: false,
  • with_anything: true,
  • with_assets: [],
  • with_classes: [],
  • with_nothing: true,
  • with_params: {},
  • with_success: '',
An early version takes a string with separate params object. A later version takes an object that includes the verb name as an object key and params as value. // valid (for now) early version this.setIOV('hold',{with_params:{max_connections:2}}); // valid later version with one verb this.setIOV( { hold: { with_params: { max_connections:2 } } } ); // valid later version with multiple verbs this.setIOVs([ { hold: { with_params: { max_connections:3 } } }, { smell: true }, ]);
setVerbSubscriptionsWithAssets(description) → {String}

Defined in: adventure/asset/setVerbSubscriptionsWithAssets.js, line 6

Parameters:

  • description String
Link assets that connect via verb subscriptions. For example, imagine "hit target with sword", where we have target.is.direct_object_of_verb.hit.with_assets:["sword"] This pass will set sword.is.indirect_object_of_verb.hit.with_assets:["target"] to ensure that both assets are in sync and either can be queried.

Returns:

String
setVerbSubscriptionsWithConnection()

Defined in: adventure/asset/setVerbSubscriptionsWithConnection.js, line 6

Make any connections specified in the game file. Assets can subscribe to verbs with is.direct_object_of_verb[verb] and some verbs make connections between assets that they act upon, which are recorded in is.direct_object_of_verb[verb].with_params.connections. Authors can preset connections in their game file, and in case they only set one of two connected assets, we want to ensure that both assets are marked as connected, so we check that here.
toggleVerbState() → {Boolean}

Defined in: adventure/asset/toggleVerbState.js, line 6

Apply the specified verb's state change to the asset.

Returns:

Boolean
tryEventHook(hook, asset_name, params) → {Boolean}

Defined in: adventure/asset/tryEventHook.js, line 6

Parameters:

  • hook string
  • asset_name string
    We use asset.name here instead of asset.id in support of authors, because we're never asking them to deal in IDs, only names. Hooks will only be defined by authors, so we let them use asset.name as their identifier. We do however make an effort to see if an id has been passed instead of a name, because Ivan.
  • params object
    Arbitrary parameter object.
Check if this asset has an event_hooks for a given event, or if the asset has an event_hooks for the same event applied to a specific asset. If either form is found, pass it to getStringOrArrayOrFunction and return the results. If the result returns false or null it will terminate the calling verb's default behavior.

Returns:

Boolean
undestroy()

Defined in: adventure/asset/undestroy.js, line 7

undestroy is called to return a destroyed asset to the game world.
unredirectVerb(oldVerb)

Defined in: adventure/asset/unredirectVerb.js, line 7

Parameters:

  • oldVerb String
unredirectVerb is a method for removing previously set verb redirects.
unsetDOV(verb)

Defined in: adventure/asset/unsetDOV.js, line 7

Parameters:

  • verb String
unsetDOV is a passthrough to unsetVerbSubscription.
unsetDOVs(verbs)

Defined in: adventure/asset/unsetDOVs.js, line 7

Parameters:

  • verbs Array
unsetDOVs is a passthrough to unsetVerbSubscription.
unsetIOV(verb)

Defined in: adventure/asset/unsetIOV.js, line 7

Parameters:

  • verb String
unsetIOV is a passthrough to unsetVerbSubscription.
unsetIOVs(verbs)

Defined in: adventure/asset/unsetIOVs.js, line 7

Parameters:

  • verbs Array
unsetIOVs is a passthrough to unsetVerbSubscription.
unsetVerbSubscription(object_of, verb)

Defined in: adventure/asset/unsetVerbSubscription.js, line 6

Parameters:

  • object_of String
  • verb String
unsetVerbSubscription disables the use of the specified verb with this asset, if it has been previously set.
validate()

Defined in: adventure/Asset.js, line 750

validate() provides an opportunity to check author-made Assets for errors before initializing them.

Properties Collapse all  |  Expand all

adjectives :Getter/Setter

Defined in: adventure/Asset.js, line 422

A list of adjectives defined for this asset in the game file. Some asset classes may have predefined adjectives. If a class has predefined adjectives, and an author creates an instance of the class with custom adjectives, the custom adjectives will be appended to the predefined ones.
article_name :Getter

Defined in: adventure/Asset.js, line 641

Getter function returns asset name preceded either by definite article or indefinite article, depending on what's set for the asset's use_definite_article_in_lists property.
articlename :Getter

Defined in: adventure/Asset.js, line 658

Todos: this should be a function, not a getter

Getter function returns asset name or proper name, depending on settings.
Articlename :Getter

Defined in: adventure/Asset.js, line 680

Returns this.articlename with propercase.
class :String

Defined in: adventure/Atom.js, line 74

Inherited from: adventurejs.Atom#class

Class identifier to be provided in the asset definition. All game objects start as generic objects that get passed to createAsset, which uses an object's class field to specify a class constructor.
collection :Getter/Setter

Defined in: adventure/Asset.js, line 293

Collection is a special property that lets one object stand in for a group of objects. For example, object desk has three drawers: top_drawer, middle_drawer, bottom_drawer. desk_drawers is a scenery object attached to desk which intercepts player input like "examine drawers", so that author can return a response like "You see three drawers."
definite_article :String

Defined in: adventure/Asset.js, line 325

Default value: 'the'

The asset's preferred definite article. Can be overridden in game file.
definite_name :Getter

Defined in: adventure/Asset.js, line 603

Getter function returns asset name preceded by its definite article, example: 'the asset'.
description :*

Defined in: adventure/Asset.js, line 709

An alias to descriptions.look.
descriptions :Object

Defined in: adventure/Asset.js, line 268

A list of descriptions for a variety of contexts. Only description is required, all others are optional. Most of these apply only to Tangible Asset.
  • descriptions.description -
  • descriptions.brief - used for room descriptions if player has typed "brief"
  • descriptions.verbose - used for room descriptions if player has typed "verbose"
  • descriptions.listen - used if player types "listen" or "listen to thing"
  • descriptions.in - used if player types "look in thing"
  • descriptions.through - used if player types "look through thing"
  • descriptions.smell - used if player types "smell thing"
  • descriptions.taste - used if player types "taste thing"
  • descriptions.touch - used if player types "touch thing"
  • descriptions.careful - used if player types "carefully examine thing"
did_do_verb :Object

Defined in: adventure/Asset.js, line 433

did_do_verb is used to track which verbs have acted upon this object.
did_do_verb_count :Object

Defined in: adventure/Asset.js, line 440

did_do_verb_count is used to track the number of times that given verbs have acted upon this object.
did_try_verb :Object

Defined in: adventure/Asset.js, line 448

did_try_verb is used to track which verbs have been tried upon this object.
did_try_verb_count :Object

Defined in: adventure/Asset.js, line 455

did_try_verb_count is used to track the number of times that given verbs have been tried upon this object.
dont_use_articles :Boolean

Defined in: adventure/Asset.js, line 352

Default value: false

An option to prevent definite/indefinite articles from appearing before an asset name. Used chiefly for characters, to prevent phrases such as "the Mrs. Beasley". Can be overridden in game file.
event_hooks :Object

Defined in: adventure/Asset.js, line 463

event_hooks is an object used to store authors' custom event hooks. There are numerous events that may be overridden. In this example, we override the onMoveThatToThis and onRemoveThatFromThis events in order to print a custom message whenever the player character enters or leaves this particular room.
MyGame.createAsset({
  class: "Room",
  name: "My Room",
  event_hooks: {
    onMoveThatToThis: 
    {
      "My Hero": function() 
      {
        MyGame.print("My Hero has come to My Room! ");
      }
    },
    onRemoveThatFromThis: 
    {
      "My Hero": function() 
      {
        MyGame.print("My Hero has left My Room. ");
      }
    },
  },
},


To learn more about event hooks... TODO
exclude_from_lookup :Boolean

Defined in: adventure/Asset.js, line 241

Default value: false

Almost all assets will be listed in the world_lookup table that is used to find assets from player input , with some exceptions, such as SceneryZones.
game :Getter

Defined in: adventure/Atom.js, line 123

Inherited from: adventurejs.Atom#game

Getter function that returns the top level game object. Use this.game.
game_name :Getter/Setter

Defined in: adventure/Atom.js, line 100

Inherited from: adventurejs.Atom#game_name

game_name holds a copy of the variable name used to store the current game instance, to which every asset in the game world holds a reference. (By default, we use "MyGame", but you can use any name.) The variable is scoped to window, and in order to get the game object, we call window[this.game_name]. Though it would be easier to use a direct object reference, doing so creates a circular reference, which complicates JSON encoding, which is how we save/restore the game state.
id :String

Defined in: adventure/Atom.js, line 86

Inherited from: adventurejs.Atom#id

A unique ID for the game asset, based on the object name provided in the asset definition.
image :String

Defined in: adventure/Asset.js, line 553

image is used to store the id of an image in game.image_lookup that is associated with this asset.
indefinite_article :String

Defined in: adventure/Asset.js, line 333

Default value: 'a'

The asset's preferred indefinite article. Can be overridden in game file.
indefinite_name :Getter

Defined in: adventure/Asset.js, line 622

Getter function returns asset name preceded by its indefinite article, example: 'an asset'.
is :Object

Defined in: adventure/Asset.js, line 76

is is a generalized container for asset states. Many states are / can be stored here. A chief benefit of this is being able to get specific states by testing asset.is.state. Note that there is also an asset.$is() method which is related to this, but is a distinct function.
is.abstract :Boolean

Defined in: adventure/Asset.js, line 187

Default value: false

Nested property of Is

Abstractions are universally available and bypass reachability tests.
is.collection :Boolean

Defined in: adventure/Asset.js, line 142

Default value: true

Nested property of Is

Set whether object is a collection of other object IDs.
is.destroyed :Boolean

Defined in: adventure/Asset.js, line 125

Default value: false

Nested property of Is

Set to true when an object is removed from the game by destruction.
is.direct_object_of_verb :Boolean

Defined in: adventure/Asset.js, line 87

Default value: {}

Nested property of Is

Used to determine whether this asset can be used as a direct object with specified verbs, and what other assets can be used with it as indirect objects.
is.direct_object_of_verb :Boolean

Defined in: adventure/Asset.js, line 99

Default value: {}

Nested property of Is

Used to determine whether this asset can be used as an indirect object with specified verbs, and what other assets can be used with it as direct objects.
is.extant :Boolean

Defined in: adventure/Asset.js, line 134

Default value: true

Nested property of Is

Set to true when an object is in the game.
is.global :Boolean

Defined in: adventure/Asset.js, line 177

Default value: false

Nested property of Is

Almost all tangible assets have a singular location. Global assets are available in all locations in order to catch player input.
is.initialized :Boolean

Defined in: adventure/Asset.js, line 158

Default value: false

Nested property of Is

Used at runtime to keep track of asset's initialization state.
is.known :Boolean

Defined in: adventure/Asset.js, line 206

Default value: false

Nested property of Is

Todos: In games with multiple characters, any character the player takes will share this knowledge. May want an option to set this per player character.

Used to track whether player knows about an asset.
is.nameless :Boolean

Defined in: adventure/Asset.js, line 166

Default value: false

Nested property of Is

Almost all assets are given a name which is then used to create their id, with some exceptions. For example, exit ids are generated by taking the name of the exit's room + the exit's direction.
is.plugged :Boolean

Defined in: adventure/assets/Tangible.js, line 181

Default value: false

Nested property of Is

Set whether this asset is plugged, like a drain.
is.pluggedIn :Boolean

Defined in: adventure/assets/Tangible.js, line 189

Default value: false

Nested property of Is

Set whether this asset is plugged in, like an appliance.
is.seen :Boolean

Defined in: adventure/assets/Tangible.js, line 236

Default value: false

Nested property of Is

Todos: In games with multiple characters, any character the player takes will share this knowledge. May want an option to set this per player character.

Used to track whether player has seen this asset. 'seen' and 'known' are distinct because a player may learn about a thing without seeing it.
is.singleton :Boolean

Defined in: adventure/Asset.js, line 195

Default value: false

Nested property of Is

Todos: Have only applied this to several special global assets, and have not implemented any code around it. Is it still useful?

Meant for use to distinguish some assets as being singular in the game world.
is.used :Boolean

Defined in: adventure/assets/Tangible.js, line 256

Default value: false

Nested property of Is

Set whether player has used this asset. Used chiefly for Exit class to say whether player has used an exit before. This figures into 'go to', which excludes exits a player has never used from its pathfinding algorithm.
is.validated :Boolean

Defined in: adventure/Asset.js, line 150

Default value: false

Nested property of Is

Used at runtime to keep track of asset's validation state.
name :String

Defined in: adventure/Atom.js, line 54

Inherited from: adventurejs.Atom#name

String provided by author in game file. The name gets serialized - which here means removing periods and spaces and converting to lowercase - and saved as a unique id for the asset.
name_is_proper :Boolean

Defined in: adventure/Asset.js, line 308

Default value: false

Used to determine whether to display a name or proper name.
noun :String

Defined in: adventure/Asset.js, line 363

noun is a string representing the type of asset this is, for example 'mug' or 'rock'. Players can input this word to refer to any asset of its type.
noun :String

Defined in: adventure/Asset.js, line 402

group is a string representing a collective category. For example, chair, bed, and desk all share a group of furniture. Players can input this word to refer to any asset of its type.
noun :String

Defined in: adventure/Asset.js, line 412

synonyms is a collection of alternate words that can be used to refer to this asset. For example, an object called 'rock' might have synonyms of ['pebble', 'stone']. Players can input synonyms to refer to this asset.
object_of_verb :Object

Defined in: adventure/Asset.js, line 38

object_of_verb is a template data structure used by asset.setVerbSubscription() to set individual assets' relationship to specified verbs. Each asset.can_be_[in]direct_object_of_verb.verb will receive the following properties and default values.
  • name: '' the name of the verb.
  • inherited_from: 'Asset' the name of the class this verb is inherited from. Since these properties aren't distinctly documented, this is offered as a convenience method for tracking down inherited verb settings.
  • enabled: true allows changing the state of an object's responsiveness to a given verb.
  • automatically: true allows for some verbs to be performed automatically if context calls for it, for example, when unlocking a door in order to pass through it. This takes precedence over global settings.
  • automatically_after_use: true if automatically if set true, this sets it so that a verb can only be applied automatically once a player has already used it.
  • then_disable: false if true, asset can only be successfully used once with given verb, but is left in place after use.
  • with_anything: true pertains only to indirect objects. If true, this asset can be used as an indirect object of this verb with any direct object.
  • with_assets: [] allows author to define a single asset that can interact with this one using the given verb, for example "unlock door with key" where key is the only asset that can unlock door.
  • with_classes: [] allows author to define an entire class that can interact with this asset using the given verb, for example "unlock door with skeleton key" where any instance of the class SkeletonKey can unlock door.
  • with_nothing: true pertains only to direct objects. If true, the specified verb can be applied to the direct object without the use of any indirect object.
  • with_success: '' is an optional parameter. Anything it contains may be appended to the end of the verb's doSuccess output.
  • then_destroy: false allows author to specify that this asset should be destroyed after using. If true, asset is destroyed after a single use regardless of how once is set. then_destroy may optionally be stored as an object that appends results to the end of doSuccess: then_destroy: { with_success: 'foo' }
plural :String

Defined in: adventure/Asset.js, line 393

plural is a string representing multiple assets of this type, for example 'swords'. Players can input this word to refer to groups of assets.
print_bold :Boolean

Defined in: adventure/Asset.js, line 227

Default value: false

Set to true to have an object's name be printed bold.
print_italic :Boolean

Defined in: adventure/Asset.js, line 234

Default value: false

Set to true to have an object's name be printed italic.
pronoun :String

Defined in: adventure/Asset.js, line 373

pronoun is a string representing the generic pronoun.
propername :String

Defined in: adventure/Asset.js, line 315

The asset's proper name, as provided in the game file. Assets can have both a name and a proper name. Used chiefly for characters, so that, for example, an asset can be both 'cat' and 'Mister Whiskers'.
quirks :Object

Defined in: adventure/Asset.js, line 113

quirks is a container for setting how to handle ambiguous verbs based on context. For example, if player inputs "stand" while sitting in a chair with quirks.stand_means_get_off set to true, player will get off the chair, as opposed to trying to stand in place on the chair.
singlePluralPairs :Array

Defined in: adventure/Asset.js, line 381

singlePluralPairs is a collection of strings representing the singular and plural forms of this asset, for example ['mug', 'mugs']. Players can use the singular to refer to a single asset or the plural to refer to a group of assets. These are stored in pairs so we can check for correspondence between the forms.
split_name_for_world_lookup :Boolean

Defined in: adventure/Asset.js, line 251

Default value: true

Object names are split into individual words for the world_lookup table. For example, given an object named "crystal sword", adventurejs creates lookup table entries for "crystal" and "sword". This lets the game recognize either word as player input, such as "get crystal" or "swing sword".

But, an author might want to name a thing, eg, "hole in the ground", in which case we wind up with lookup table entries for "hole" and "in" and "the" and "ground", which is likely to lead to bad input parsing. To avoid name splitting, set split_name_for_world_lookup to false. The object's full name will still be added to the lookup.
UID :String

Defined in: adventure/Atom.js, line 93

Inherited from: adventurejs.Atom#UID

A unique numerical ID for the game asset. Currently unused but included as a potential alternative to id.
use_definite_article_in_lists :Boolean

Defined in: adventure/Asset.js, line 341

Default value: false

A preference for how an asset's name appears when it is printed in certain contexts. Chiefly used for room names. For example, you might name a room 'Sitting Room', but want it to appear as 'the Sitting Room' in some contexts for narrative clarity. Can be overridden in game file.
verb_hooks :Object

Defined in: adventure/Asset.js, line 498

verb_hooks is an object used to store an authors' custom verb hooks for this asset. Any verb may be overridden for any singular asset. In this example, we hook the take.doBeforeTry, take.doAfterTry, take.doBeforeSuccess, take.doAfterSuccess, and drop.doAfterSuccess events in order to print custom messages as the player interacts with this asset.
MyGame.createAsset({
  class: "Sword",
  name: "singing sword",
  verb_hooks: {
    take: 
    {
      doBeforeTry: function( params )
      {
        MyGame.print( "The sword quivers as you reach for 
        it. ", "concatenate_output" );
      },
      doAfterTry: function( params )
      {
        MyGame.print( "The sword begins to vibrate as your hand 
        curls around its haft. ", "concatenate_output" );
      },
      doBeforeSuccess: function( params )
      {
        MyGame.print( "The sword's vibration grows into a hum. ", 
        "concatenate_output" );
      },
      doAfterSuccess: function( params )
      {
        MyGame.print( "The sword bursts into full on song in your hand. ", 
        "concatenate_output" );
      },
    },
    drop: 
    {
      doAfterSuccess: function( params )
      {
        MyGame.print( "The sword bursts into a tearful dirge as it 
        falls to the floor. ", "concatenate_output" );
      },
    },
  },
});


To learn more about verb hooks... TODO
Documentation generated by JSDoc 3.6.11 on Mon Nov 20 2023 18:01:07 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to docs@adventurejs.com.