Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Adam

Defined in: adventure/Adam.js, line 5

Framework class

Adam is an experimental copy of the Asset base class, being used to test the Javascript ES6 class keyword.

The Asset class is used to create all Assets in the game world. It defines several important base properties including name, class, id, and the set method. Authors should not need to instantiate or subclass Adam. Start with the Tangible class to create new physical Assets, or the Intangible class to create new abstract Assets.

Private Constructor:

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


  • game_name String
    A reference back to the top level game object, by way of window[game_name]. Done this way rather than using an object reference in order to avoid circular references, because they're difficult to parse into JSON, the method that's used for saving/restoring game data.
  • name String
    The name of the object in the game world, ie "brass lantern". The name is also used to create the object's id.
Inherited Overrides


Methods Collapse all  |  Expand all

getInheritance() → {Array}

Defined in: adventure/Adam.js, line 234

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


hasClass(prop) → {Boolean}

Defined in: adventure/Adam.js, line 212


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



Properties Collapse all  |  Expand all

class :String

Defined in: adventure/Adam.js, line 81

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/Adam.js, line 122

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

Defined in: adventure/Adam.js, line 107

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/Adam.js, line 93

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

Defined in: adventure/Adam.js, line 57

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 :String

Defined in: adventure/Adam.js, line 67

Name returns the name of the class instance with the first character uppercased.
UID :String

Defined in: adventure/Adam.js, line 100

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:01:05 GMT-0800 (Pacific Standard Time)
Found a problem or error in the docs? Report it to