Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Vessel

Extends: adventurejs.Atom

Defined in: adventure/assets/Vessel.js, line 6

How to: UseSubstanceVessels

Framework class

Vessel is a special class that adds the ability to contain substances to Tangible Assets. Vessels must exist within Aspects, which exist within Tangibles. In other words, Tangible.Aspect.Vessel, or as a practical example:


  class: "Bowl",
  name: "stone bowl",
  place: { on: "blood stained shrine" },
  descriptions:{look:"It's a stained, chipped stone bowl. ",} 
    vessel: {
      maxvolume: 500,
      volume: 350,
      substance_id: "viscous fluid",

To learn more, see how to Use Substances.

Private Constructor:

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


  • game_name String
    Name of top level game instance that is scoped to window.
  • name String
    Instance name.
Inherited Overrides




Methods Collapse all  |  Expand all


Defined in: adventure/assets/Vessel.js, line 442


  • volume number
    The volume to add to the vessel.
addVolume is called to raise the vessel's volume by a specified amount.
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.


getProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 184

Inherited from: adventurejs.Atom#getProperty


  • 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 "". Returns false if property doesn't exist, so beware of if(false === comparisons.


getVolume() → {number}

Defined in: adventure/assets/Vessel.js, line 394

empty sets the volume of this vessel to 0.


getVolume() → {number}

Defined in: adventure/assets/Vessel.js, line 411

getVolume is called to get the current volume of this vessel. Takes into consideration whether vessel is emitting.


hasClass(prop) → {Boolean}

Defined in: adventure/Atom.js, line 216

Inherited from: adventurejs.Atom#hasClass


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


hasProperty(prop) → {Boolean}

Defined in: adventure/Atom.js, line 148

Inherited from: adventurejs.Atom#hasProperty


  • 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 "". 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.


set(props) → {Object}

Defined in: adventure/Atom.js, line 134

Inherited from: adventurejs.Atom#set


  • 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.


Object Returns the instance the method is called on (useful for chaining calls.)

Defined in: adventure/assets/Vessel.js, line 428


  • volume number
    The volume to set the vessel to.
setVolume is called to set a vessel to a specified volume.

Defined in: adventure/assets/Vessel.js, line 461


  • volume number
    The volume to subtract from the vessel.
subtractVolume is called to reduce the vessel's volume by a specified amount.

Properties Collapse all  |  Expand all

can_drain :Getter

Defined in: adventure/assets/Vessel.js, line 129

Default value: false

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.
game :Getter

Defined in: adventure/Atom.js, line 123

Inherited from: adventurejs.Atom#game

Getter function that returns the top level game object. Use
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.
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.
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.
Documentation generated by JSDoc 3.6.11 on Mon Nov 20 2023 18:02:58 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to