Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0

Defined in: adventure/Game.js, line 5

Constructor:

var MyGame = new adventurejs.Game( "MyGame", "MyGameDisplay" )

Description

Game is used to construct a new game instance. This instance contains the entire game and all of its methods. If you open the browser inspector window, go to the console, and type "MyGame" (or whatever game_name you have provided), you can see the properties scoped to the Game object. Every object in the game is given a reference back to the main Game object. This means that you can run multiple games in a single HTML page.

Example:

A minimal game defines at least one Room and one Player Character. If you don't provide either of these, one will be created automatically.

var MyGame = new adventurejs.Game( "MyGame", "MyGameDisplay" )
.set({
  title: "Welcome Game",
  author: "Ivan Cockrum",
  description: "This is my great game! Thanks for playing!",
  version: "0.0.1",
});

MyGame.createAsset({
  class: "Room",
  name: "Welcome Room",
  descriptions:{ look: "You've entered the Welcome Room. " },
});

MyGame.createAsset({
  class: "Player",
  name: "Guest",
  is: { active: true, },
  place: { in: "Welcome Room" },
});

Private Constructor:

var foo = new adventurejs.Game(game_nameopt, displayElIdopt)

Parameters:

  • game_name String <optional>
    Default value: ""
    A string that matches the name of the var used to store the new Game instance. Used to give the game a reference back to itself, relative to the browser window. If no name is provided, the instance name will default to "MyGame". The chief reason you might want to use a custom game_name is if you want to run multiple instance of adventure.js on a single page; give them distinct names to prevent them from colliding. You also may want to refer to your Game instance if you write any custom javascript.
  • displayElId String <optional>
    Default value: ""
    A string that matches the ID of an existing DOM element into which to insert the game Display. If no ID is provided, a DOM element will be created with an ID of "MyGameDisplay" and class of "ajs-display", and appended to .
Inherited Overrides

Index

Methods:

Properties:

Methods Collapse all  |  Expand all

addAsset
addAsset(asset) → {Object}

Defined in: adventure/game/addAsset.js, line 7

Parameters:

  • asset Object
    A generic object with properties to copy into a new classed object.
MyGame.addAsset({ "class":"foo", "name":"bar", [...] })

addAsset() is a constructor function that can be used to dynamically create new Assets at runtime, which is to say, after the game has been initialized. This method encapsulates game.createAsset(), asset.validate() and asset.initialize(). The end result is equivalent to using createAsset() in your game file.

Returns:

Object A new Asset of the class specified in asset.class.
addPronouns
addPronouns(oldVerb, newVerb) → {object}

Defined in: adventure/Game.js, line 632

Parameters:

  • oldVerb object
  • newVerb object
This convenience method is a shortcut to game.dictionary.addPronouns().

Returns:

object
appendOutput
appendOutput(msg) → {boolean}

Defined in: adventure/Game.js, line 464

Parameters:

  • msg String
Convenience method is a shortcut to game.parser.input_history[ 0 ].appendOutput(). Provides a method for author to append custom text after default output for the turn.

Returns:

boolean
callIntervals
callIntervals()

Defined in: adventure/game/callIntervals.js, line 7

callIntervals uses pointers to asset properties to print messages or apply custom logic every turn. For example, turn on a water faucet and have the faucet pour water every turn until it's turned off, or turn on a radio and have it play music lyrics. Properties can be strings or arrays or functions.
callPostScripts
callPostScripts()

Defined in: adventure/Game.js, line 720

callPostScripts calls any arbitrary functions defined by the author.
callPreScripts
callPreScripts()

Defined in: adventure/Game.js, line 701

callPreScripts calls any arbitrary functions defined by the author.
capitalize
capitalize(string) → {String}

Defined in: adventure/utils/capitalize.js, line 4

Parameters:

  • string String
Capitalizes the first character of a string.

Returns:

String
clearInput
clearInput()

Defined in: adventure/Game.js, line 392

An alias to method display.clearInput.
clearPrompt
clearPrompt()

Defined in: adventure/game/clearPrompt.js, line 8

Clear a user prompt.
combineVerbs
combineVerbs(verbs, intoVerb) → {object}

Defined in: adventure/Game.js, line 607

Parameters:

  • verbs object
  • intoVerb object
This convenience method is a shortcut to game.dictionary.combineVerbs().

Returns:

object
constructAsset
constructAsset(source) → {Object}

Defined in: adventure/game/constructAsset.js, line 8

Parameters:

  • source Object
    A generic object containing properties to copy to a game object.
Takes a generic object and returns a classed object.

Returns:

Object Returns an instance of whatever class was defined.
convertTemperature
convertTemperature(temperature, context_id) → {Boolean}

Defined in: adventure/utils/convertTemperature.js, line 3

Todos: Finish writing this.

Parameters:

  • temperature Number | String
    In Celsius.
  • context_id String
    The ID of the game object the temperature applies to.

Returns:

Boolean
createAsset
createAsset(asset) → {Object}

Defined in: adventure/game/createAsset.js, line 7

Parameters:

  • asset Object
    A generic object with properties to copy into a new classed object.
MyGame.createAsset({ "class":"foo", "name":"bar", [...] })

createAsset() is a constructor function available to authors, for creating all instances of Asset and its subclasses, which includes most of the objects you'd put in a game world.

The function takes one parameter: a generic object containing properties to be passed into a class instance. For most asset classes, the only required properties are 'class' and 'name'. You'd likely also want to specify 'location', though that's not a required property. Otherwise, an author only needs to define the properties they wish to revise away from default settings.

For example, to create a simple brass key with default settings and put it in a particular location:

MyGame.createAsset({
  "class":"Key",
  "name":"brass key",
  place: { in: "desk drawer" },
});

At runtime, createAsset() returns a new instance of the given class, uses the given name to create an id, validates the object properties, initializes the new object, and then adds it to the game world. Failure to pass any of these steps will throw an error to the console.

For more examples of how to use createAsset, see About Assets and other How To docs under Getting Started.

Returns:

Object A new Asset of the class specified in asset.class.
createClass
createClass(data) → {Object}

Defined in: adventure/game/createClass.js, line 7

Parameters:

  • data Object
    A generic object with properties to copy into a new class definition.
    Properties
    • parent String
      The name of a parent class to subclass.
    • class String
      The name of the new subclass.
MyGame.createClass(
  class Foo extends adventurejs.Bar {
    constructor(name, game_name) {
      super(name, game_name);
      this.class = "Foo";
    }
  }
)

createClass() is a constructor function available to authors for creating whole new classes of Assets. The function takes one parameter: a class declaration function. For example, to create a special class of Yggdrasil tree:

MyGame.createClass({
 parent: "Tree",
 class: "Yggdrasil",
})

At runtime, createClass() plugs the new class constructor directly into AdventureJS, where it can be used to construct instances with the usual Game.createAsset({}) method. As of this writing, createClass is basically a passthrough without any internal error checking, so consider yourself going off road. It's recommended that you browse through the Asset Reference to see how classes are laid out.

You can also find more info under Custom Classes.

Returns:

Object
createCompass
createCompass(properties) → {Object}

Defined in: adventure/game/createCompass.js, line 7

Parameters:

  • properties Object
    A generic object with properties used to construct a compass.
createCompass is an alias to method game.display.createCompass()

Returns:

Object A new compass object.
createDeferredAssets
createDeferredAssets()

Defined in: adventure/game/createDeferredAssets.js, line 8

Create objects - mainly exits - that were defined within other unclassed generic objects.

Objects created here also need to be validated, since they were added to the deferred list during the initial validation pass and therefore missed validation.
createDock
createDock(properties) → {Object}

Defined in: adventure/game/createDock.js, line 7

Parameters:

  • properties Object
    A generic object with properties used to construct the verb dock.
createDock is an alias to method game.display.createDock()

Returns:

Object A new verb dock object.
createGlobalCeilings
createGlobalCeilings()

Defined in: adventure/game/createGlobalCeilings.js, line 8

Create global ceiling (although there's only one).
createGlobalConcepts
createGlobalConcepts()

Defined in: adventure/game/createGlobalConcepts.js, line 8

Create global concepts. Each item is a singular instance of a unique class.
createGlobalExits
createGlobalExits()

Defined in: adventure/game/createGlobalExits.js, line 8

Create global exits.
createGlobalFloors
createGlobalFloors()

Defined in: adventure/game/createGlobalFloors.js, line 8

Create global floors (although there's only one).
createGlobalScenery
createGlobalScenery()

Defined in: adventure/game/createGlobalScenery.js, line 8

Create global scenery. Each item is an instance of the Scenery class.
createGlobalWalls
createGlobalWalls()

Defined in: adventure/game/createGlobalWalls.js, line 8

Create global walls.
createImageLookup
createImageLookup(asset) → {Object}

Defined in: adventure/game/createImageLookup.js, line 7

Parameters:

  • asset Object
    A generic object with properties to copy into the image library.
createImageLookup() is a method used to create an image lookup. Generally used for setting room background images. The function takes one parameter: a generic object containing an array of image id/url pairs.
MyGame.createImageLookup({
  images: [
    { id: "desert", image: "images/backgrounds/desert.jpg" },
    { id: "sea", image: "images/backgrounds/sea.jpg" },
    { id: "mountains", image: "images/backgrounds/mountains.jpg" },
    { id: "dungeon", image: "images/backgrounds/dungeon.jpg" },
    { id: "throneroom", image: "images/backgrounds/throneroom.jpg" },
  ],
});
The image library is accessible at game.image_lookup.

Returns:

Object A reference to the image lookup.
createPostScript
createPostScript(object) → {Object}

Defined in: adventure/game/createPostScript.js, line 7

Parameters:

  • object Object
    A generic object with properties to copy into a new classed object.
Utility to allow authors to inject custom scripts to be called after inputParseComplete, aka end of turn.

Returns:

Object The object that was passed in.
createPreScript
createPreScript(object) → {Object}

Defined in: adventure/game/createPreScript.js, line 7

Parameters:

  • object Object
    A generic object with properties to copy into a new classed object.
Utility to allow authors to inject custom scripts to be called after parseInput and before inputParseBegin, allowing complete override of turn.

Returns:

Object The object that was passed in.
createVerb
createVerb(verb) → {object}

Defined in: adventure/Game.js, line 582

Parameters:

  • verb object
This convenience method is a shortcut to game.dictionary.createVerb().

Returns:

object
debug
debug(token)

Defined in: adventure/game/debug.js, line 7

Parameters:

  • token String
Prep the supplied string for printing to the display.
decrypt
decrypt(text) → {String}

Defined in: adventure/utils/decrypt.js, line 5

Parameters:

  • text String
Decrypt a string. Used to make point and hint data non human readable via encryption.

Returns:

String
decVar
decVar()

Defined in: adventure/Game.js, line 827

Decrement a custom var stored in this.world._vars. Default value is 1. Vars stored here are written to save files.
deobfuscate
deobfuscate(text) → {String}

Defined in: adventure/utils/deobfuscate.js, line 5

Parameters:

  • text String
Obfuscate a string. Used to make saved game files non human readable.

Returns:

String
disableAllVerbsBut
disableAllVerbsBut(verbs) → {object}

Defined in: adventure/Game.js, line 558

Parameters:

  • verbs object
This convenience method is a shortcut to game.dictionary.disableAllVerbsBut().

Returns:

object
disableVerbs
disableVerbs(verbs) → {object}

Defined in: adventure/Game.js, line 546

Parameters:

  • verbs object
This convenience method is a shortcut to game.dictionary.disableVerbs().

Returns:

object
doTravel
doTravel(direction, params)

Defined in: adventure/game/doTravel.js, line 8

Parameters:

  • direction String
  • params Object
Tries to move the subject in the specified direction.
enableVerbs
enableVerbs(verbs) → {object}

Defined in: adventure/Game.js, line 570

Parameters:

  • verbs object
This convenience method is a shortcut to game.dictionary.enableVerbs().

Returns:

object
endTurn
endTurn()

Defined in: adventure/Game.js, line 739

endTurn calls methods to update displays and print per-turn statements.
findSubstanceBodyOrHeld
findSubstanceBodyOrHeld(substance_id) → {Array}

Defined in: adventure/game/findSubstanceBodyOrHeld.js, line 8

Parameters:

  • substance_id String
Find assets containing the specified substance.

Returns:

Array
findSubstanceContainers
findSubstanceContainers(substance_id, context, selects) → {Array}

Defined in: adventure/game/findSubstanceContainers.js, line 8

Parameters:

  • substance_id String
  • context Object
  • selects Array
Find assets containing the specified substance.

Returns:

Array
findViewModifiers
findViewModifiers() → {Array}

Defined in: adventure/game/findViewModifiers.js, line 8

Find assets that may modify other asset descriptions, such as viewports (like eyeglasses), viewpoints (nests from which things may look different), and light sources such as flashlights and candles.

Returns:

Array
getAreaScenery
getAreaScenery(asset, identifier) → {String}

Defined in: adventure/game/getAreaScenery.js, line 8

Parameters:

  • asset Object | String
  • identifier String

Global assets are a bit (perhaps overly) complicated. They exist as singular objects in the game world, and they can be enabled/disabled and have their descriptions overridden per room and per zone.

For example:

  • MyGame.world.global_air is an asset
  • MyGame.world.room.area_scenery.global_air is a simple object property that can be used to determine whether a global asset is available in a given room.
  • MyGame.world.zone.area_scenery.global_air is a simple object property that can be used to determine whether a global asset is available in a given zone.
  • Though global asset is singular, its description can be overridden by descriptions set in area_scenery and area_scenery.

    Returns:

    String A description of the specified asset id.
    getAsset
    getAsset(identifier, params) → {String}

    Defined in: adventure/game/$.js, line 8

    Parameters:

    • identifier String
      Name or ID of a game object.
    • params Object
      Used to check for 'prefer_substance' in cases of looking for substances in containers.
    $ takes a string representing an asset name or id and tries to return an asset object.

    Returns:

    String An object ID.
    getAsset
    getAsset(identifier, params) → {Object}

    Defined in: adventure/game/getAsset.js, line 8

    Parameters:

    • identifier String
      Name or ID of a game object.
    • params Object
      Used to check for 'prefer_substance' in cases of looking for substances in containers.
    getAsset takes a string representing an asset name or id and tries to return an asset object.

    Returns:

    Object A game asset.
    getDescription
    getDescription(identifier) → {String|Boolean}

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

    Parameters:

    • identifier 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 scoped to Game rather than Asset because there are cases that handle simple unclassed objects with description properties, notably: properties of area_scenery.

    Returns:

    String | Boolean
    getDirections
    getDirections() → {Object}

    Defined in: adventure/game/getDirections.js, line 8

    Convenience method to get the exit directions of the current room asset.

    Returns:

    Object
    getExitFromDirection
    getExitFromDirection(direction) → {Object}

    Defined in: adventure/game/getExitFromDirection.js, line 8

    Parameters:

    • direction String
    Does current room have an exit in that direction? If not use global exit. Always applies to current room. If no exit found, returns false.

    Returns:

    Object An exit.
    getExits
    getExits() → {Object}

    Defined in: adventure/game/getExits.js, line 8

    Convenience method to get the exits of the current room asset.

    Returns:

    Object
    getExtendedExitName
    getExtendedExitName(exit, destination) → {String}

    Defined in: adventure/game/getExtendedExitName.js, line 8

    Parameters:

    • exit Object
    • destination Object

    Returns:

    String
    getInput
    getInput() → {Object}

    Defined in: adventure/game/getInput.js, line 8

    Convenience method to get this turn's input.

    Returns:

    Object
    getLastTurn
    getLastTurn() → {Object}

    Defined in: adventure/game/getLastTurn.js, line 8

    Convenience method to get this turn's input.

    Returns:

    Object
    getLongestKey
    getLongestKey()

    Defined in: adventure/game/getLongestKey.js, line 8

    Get the key with the longest word count in the world lookup table. Used for iterating through lookup table from longest to shortest.
    getModifiedDescription
    getModifiedDescription(options) → {String}

    Defined in: adventure/game/getModifiedDescription.js, line 6

    Parameters:

    • options Object
    Get modified descriptions, such as "look at this through magnifying glass with candle", where "through magnifying glass, with candle" is a key at asset.descriptions.look["through magnifying glass, with candle"]. "look" is always the default description, but any identifier can have modifiers.

    This is scoped to Game rather than Asset because there are cases that handle simple unclassed objects with description properties, notably: properties of area_scenery.

    Returns:

    String
    getPlayer
    getPlayer() → {Object}

    Defined in: adventure/game/getPlayer.js, line 8

    Convenience method to get the player asset.

    Returns:

    Object
    getPrintableObjectList
    getPrintableObjectList(objects, exclusions) → {String}

    Defined in: adventure/game/getPrintableObjectList.js, line 8

    Parameters:

    • objects Object
      An array of object ID strings.
    • exclusions Object
      An array of of object ID strings to exclude.

    Returns:

    String A formatted string.
    getRoom
    getRoom() → {Object}

    Defined in: adventure/game/getRoom.js, line 8

    Convenience method to get the current room asset.

    Returns:

    Object
    getRoomContents
    getRoomContents(room)

    Defined in: adventure/game/getRoomContents.js, line 8

    Parameters:

    • room Object
      A room to be printed. Defaults to current room.
    getRoomDescription
    getRoomDescription(params)

    Defined in: adventure/game/getRoomDescription.js, line 8

    Todos: Formalize handling for description/brief/verbose descriptions

    Parameters:

    • params Object
    Get room description to print to game display. Includes input, room name, and room description. Defaults to current room, but can accept a room param. Calling the function with params.verbose set to true will override global verbosity settings and try to print a verbose description.

    For example:
    getRoomDescription( { verbose: true } )
    getRoomExits
    getRoomExits(room) → {String}

    Defined in: adventure/game/getRoomExits.js, line 8

    Parameters:

    • room Object
      A room to get exits of. Defaults to current room.

    Returns:

    String A formatted list of exits.
    getRoomFloor
    getRoomFloor() → {Object}

    Defined in: adventure/game/getRoomFloor.js, line 8

    Convenience method to get the current room's floor.

    Returns:

    Object
    getStringLookup
    getStringLookup(verbs) → {object}

    Defined in: adventure/Game.js, line 508

    Parameters:

    • verbs object
    This convenience method is a shortcut to game.dictionary.getStringLookup().

    Returns:

    object
    getSubject
    getSubject() → {Object}

    Defined in: adventure/game/getSubject.js, line 8

    Convenience method to get the current subject asset. Usually this would be the player, unless player has input something like "Floyd, go east"

    Returns:

    Object
    getVar
    getVar()

    Defined in: adventure/Game.js, line 778

    Get a custom var stored in this.world._vars. Vars stored here are written to save files.
    getVar
    getVar()

    Defined in: adventure/Game.js, line 850

    Test if there is a custom var stored in this.world._vars. Vars stored here are written to save files.
    getVerb
    getVerb(verb) → {object}

    Defined in: adventure/Game.js, line 533

    Parameters:

    • verb string
    Get the dictionary verb corresponding to provided string. This convenience method is a shortcut to game.dictionary.getVerb().

    Returns:

    object
    getVerifiedSentence
    getVerifiedSentence() → {Object}

    Defined in: adventure/game/getVerifiedSentence.js, line 8

    Convenience method to get this turn's verified sentence.

    Returns:

    Object
    getWordCount
    getWordCount() → {Array}

    Defined in: adventure/game/getWordCount.js, line 7

    getWordCount() is a utility method to get a count of all the unique words the game "knows".

    Returns:

    Array
    hasCommonWord
    hasCommonWord(word) → {boolean}

    Defined in: adventure/Game.js, line 520

    Parameters:

    • word string
    Look for a common word in the dictionary. This convenience method is a shortcut to game.dictionary.hasCommonWord().

    Returns:

    boolean
    hasVerb
    hasVerb(verb) → {Boolean}

    Defined in: adventure/game/hasVerb.js, line 8

    Parameters:

    • verb String
    Convenience method to ask whether this game has specified verb.

    Returns:

    Boolean
    hideStatusbar
    hideStatusbar() → {boolean}

    Defined in: adventure/Game.js, line 647

    This convenience method is a shortcut to game.display.hideStatusbar().

    Returns:

    boolean
    idleNPCs
    idleNPCs()

    Defined in: adventure/Game.js, line 671

    idleNPCs performs actions or prints messages defined in NPC.idle, for NPCs in the current room. Properties can be strings or arrays or functions.
    incVar
    incVar()

    Defined in: adventure/Game.js, line 804

    Increment a custom var stored in this.world._vars. Default value is 1. Vars stored here are written to save files.
    initializeAssets
    initializeAssets()

    Defined in: adventure/game/initializeAssets.js, line 8

    Initialize all game assets.
    isCurrentRoom
    isCurrentRoom() → {Object}

    Defined in: adventure/game/isCurrentRoom.js, line 8

    Tests whether the current room matches the provided name or id.

    Returns:

    Object
    log
    log(method, level, msg)

    Defined in: adventure/game/log.js, line 7

    Parameters:

    • method String | Number
      0=log, 1=warn, 2=error
    • level String | Number
      0=critical, 1=high, 2=medium, 3=low
    • msg *
      Message for console.
    Custom logging function.
    midTurn
    midTurn()

    Defined in: adventure/Game.js, line 755

    midTurn calls methods to update displays during queued verb actions.
    modifyVerb
    modifyVerb(verb) → {object}

    Defined in: adventure/Game.js, line 620

    Parameters:

    • verb object
    This convenience method is a shortcut to game.dictionary.modifyVerb() ).

    Returns:

    object
    overrideOutput
    overrideOutput(msg) → {boolean}

    Defined in: adventure/Game.js, line 478

    Parameters:

    • msg String
    This convenience method is a shortcut to game.parser.input_history[ 0 ].overrideOutput(). Provides a method for author to override default text output for the turn.

    Returns:

    boolean
    play
    play()

    Defined in: adventure/game/play.js, line 8

    Validate and initialize all classed game objects in world. Validation is internal to each object. Initialization draws connections to other objects.

    Returns:

    adventurejs.Game
    prependOutput
    prependOutput(msg) → {boolean}

    Defined in: adventure/Game.js, line 492

    Parameters:

    • msg String
    This convenience method is a shortcut to game.parser.input_history[ 0 ].prependOutput(). Provides a method for author to prepend custom text before default output for the turn.

    Returns:

    boolean
    print
    print(msg, classes)

    Defined in: adventure/game/print.js, line 7

    Parameters:

    • msg String
    • classes String
    Prep the supplied string for printing to the display.
    print
    print(msg, classes)

    Defined in: adventure/game/printInferred.js, line 7

    Parameters:

    • msg String
    • classes String
    Print an inference to the display, appending it to the turn's input.
    printAreaEvents
    printAreaEvents()
    printPlayerInventory
    printPlayerInventory()
    printQueue
    printQueue()

    Defined in: adventure/game/printQueue.js, line 7

    Print queued outputs.
    printRoom
    printRoom(params)

    Defined in: adventure/game/printRoom.js, line 8

    Todos: Formalize handling for description/brief/verbose descriptions

    Parameters:

    • params Object
    Print room description to game display. Includes input, room name, and room description. Defaults to current room, but can accept a room param. Calling the function with params.verbose set to true will override global verbosity settings and try to print a verbose description.

    For example:
    printRoom( { verbose: true } )
    printRoomExits
    printRoomExits(room)

    Defined in: adventure/game/printRoomExits.js, line 8

    Parameters:

    • room Object
      A room to be printed. Defaults to current room.
    printWithInput
    printWithInput(msg, classes)

    Defined in: adventure/game/printWithInput.js, line 8

    Parameters:

    • msg String
    • classes String
    promptUser
    promptUser()

    Defined in: adventure/game/promptUser.js, line 8

    Prompt user to press a key to continue.
    removePostScript
    removePostScript(key)

    Defined in: adventure/game/removePostScript.js, line 7

    Parameters:

    • key String
      The key of a previously defined postScript.
    Utility to allow authors to remove postScripts they have previously set.
    removePreScript
    removePreScript(key)

    Defined in: adventure/game/removePreScript.js, line 7

    Parameters:

    • key String
      The key of a previously defined prescript.
    Utility to allow authors to remove preScripts they have previously set.
    replaceVerb
    replaceVerb(oldVerb, newVerb) → {object}

    Defined in: adventure/Game.js, line 594

    Parameters:

    • oldVerb object
    • newVerb object
    This convenience method is a shortcut to game.dictionary.replaceVerb().

    Returns:

    object
    sendToInput
    sendToInput()

    Defined in: adventure/Game.js, line 383

    An alias to method display.sendToInput.
    sendToParser
    sendToParser()

    Defined in: adventure/Game.js, line 371

    Takes an input and immediately forwards it to the parser.
    set
    set(props) → {adventurejs.Game}

    Defined in: adventure/game/set.js, line 8

    Parameters:

    • props Object
      A generic object containing properties to copy to the Game instance.
    This is a shallow copy for setting global properties on the main game object. Returns the game object for chaining.

    Returns:

    adventurejs.Game Returns the instance the method is called on (useful for chaining calls.)
    setAreaScenery
    setAreaScenery(globals)

    Defined in: adventure/game/setAreaScenery.js, line 8

    Parameters:

    • globals Object
      A list of globle Scenery Assets.
    A method to let author set default descriptions for global objects such as sun, moon, sky, floor, walls.
    setPlayer
    setPlayer(new_player) → {Object}

    Defined in: adventure/Game.js, line 860

    Parameters:

    • new_player *
      id or object representing new player
    Swap the active player character. If a room is passed, new player is moved to that room. If no room is passed and player is in a room, that room is set to current room. If no room is passed and player is not in a room, player is moved to current room.

    Returns:

    Object
    setRoom
    setRoom(newRoom, params)

    Defined in: adventure/game/setRoom.js, line 8

    Parameters:

    • newRoom Object
      A room object to which to move subject.
    • params Object
    Move subject to the specified room.
    setStyle
    setStyle(style, params)

    Defined in: adventure/game/setStyle.js, line 8

    Parameters:

    • style Object
      A room object to which to move subject.
    • params Object
    setStyle offers a method to add custom stylesheets via the game definition file, as opposed to embedding styles in HTML or loading stylesheets.
    setVar
    setVar()

    Defined in: adventure/Game.js, line 789

    Set a custom var stored in this.world._vars. Vars stored here are written to save files.
    showStatusbar
    showStatusbar() → {boolean}

    Defined in: adventure/Game.js, line 658

    This convenience method is a shortcut to game.display.showStatusbar().

    Returns:

    boolean
    sortLookupValues
    sortLookupValues()

    Defined in: adventure/game/sortLookupValues.js, line 8

    Sort lookupTable values that contain multiple IDs.
    startInterval
    startInterval(params)

    Defined in: adventure/game/startInterval.js, line 7

    Parameters:

    • params Object
      The parameters for the interval.
      Properties
      • id string
        Default value:
        The id of the Asset which owns the function.
      • callback function
        Default value:
        The function to call on each interval.
      • times number <optional>
        Default value: null
        The number of turns to repeat, or null for indefinite.
      • frequency number <optional>
        Default value: 1
        How often to trigger, in turns.
    Intervals are callback functions used to fire in-game events every turn. For example, turn on a water faucet and the faucet pours water every turn until it's turned off. startInterval adds functions to the list. The optional turns parameter allows for setting a limit on the number of turns to repeat.
    stopInterval
    stopInterval(params)

    Defined in: adventure/game/stopInterval.js, line 7

    Parameters:

    • params Object
      The parameters for the interval.
      Properties
      • id string
        The id of the Asset which owns the function.
      • callback function
        The function to stop.
    Intervals are callback functions used to fire in-game events every turn. For example, turn on a water faucet and the faucet pours water every turn until it's turned off. stopInterval removes callback functions from the list.
    tryTravel
    tryTravel(direction, params)

    Defined in: adventure/game/tryTravel.js, line 8

    Parameters:

    • direction String
    • params Object
    Tries to move the subject in the specified direction.
    tryTravelOld
    tryTravelOld(direction, params)

    Defined in: adventure/game/tryTravelOld.js, line 8

    Parameters:

    • direction String
    • params Object
    Tries to move the subject in the specified direction.
    validateAssetPrecursor
    validateAssetPrecursor(child) → {Object}

    Defined in: adventure/game/validateAssetPrecursor.js, line 8

    Parameters:

    • child Object
      A generic object.
    Validate unclassed precursor object prior to creating an asset. Generic objects must have at minimum a valid class and a name. Name is used to generate ID. Exits are the exception, where ID is generated from location + direction.

    Returns:

    Object A classed object.
    validateAssets
    validateAssets()

    Defined in: adventure/game/validateAssets.js, line 8

    Validate all assets in world.
    vars
    vars()

    Defined in: adventure/Game.js, line 766

    This convenience property is a shortcut to game.world._vars, which is a container for any game variables set by authors. Variables stored here are saved within the scope of data that gets written to save files.

    Properties  | 

    author
    author :String

    Defined in: adventure/Settings.js, line 1226

    Default value: ""

    Get/set game author and pass to Display.
    baseline
    baseline

    Defined in: adventure/Game.js, line 207

    baseline stores a copy of the initial game world, for comparison in save/restore and undo.
    class_lookup
    class_lookup

    Defined in: adventure/Game.js, line 231

    class_lookup stores a lookup table containing the ids of all assets by class.
    doStartGame
    doStartGame :Object

    Defined in: adventure/Game.js, line 355

    If doStartGame is set to a function, it will be called when the game starts. Provided to allow authors to call arbitrary code on game start.
    game
    game :Object

    Defined in: adventure/Game.js, line 111

    Default value: {}

    A reference back to this Game object. Chiefly used for consistency so we can refer to this.game, which is how we refer back to the Game from many functions.
    game_name
    game_name :String

    Defined in: adventure/Game.js, line 120

    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.
    game_states
    game_states :Object

    Defined in: adventure/Game.js, line 79

    Default value: {}

    An enum for storing game_states values.
    goalcard
    goalcard :Object

    Defined in: adventure/Game.js, line 327

    goalcard is a singleton class that stores all the game's goal data and functions for managing goals.
    hintcard
    hintcard :Object

    Defined in: adventure/Game.js, line 319

    hintcard is a singleton class that stores all the game's hint data and functions for managing hints.
    image_lookup
    image_lookup

    Defined in: adventure/Game.js, line 245

    image_lookup stores a lookup table for optional images supplied by author.
    input
    input :Object

    Defined in: adventure/Game.js, line 434

    Deprecated
    • Use game.getInput() instead.
    Convenience method to get this turn's input.
    introcard
    introcard :Object

    Defined in: adventure/Game.js, line 335

    introcard is a singleton class used for printing the game's intro screen.
    last_turn
    last_turn :Object

    Defined in: adventure/Game.js, line 443

    Deprecated
    • Use game.getLastTurn() instead.
    Convenience method to get last turn.
    longest_key
    longest_key

    Defined in: adventure/Game.js, line 222

    longest_key stores the world_lookup key with the highest word count, which is used for iterating through world_lookup from longest to shortest.
    outrocard
    outrocard :Object

    Defined in: adventure/Game.js, line 342

    outrocard is a singleton class used for printing the game's outro screen.
    player
    player :Object

    Defined in: adventure/Game.js, line 416

    Deprecated
    • Use game.getPlayer() instead.
    Convenience method to get the player.
    reactor
    reactor :Object

    Defined in: adventure/Game.js, line 139

    Default value: {}

    An object used to manage javascript events.
    room
    room :Object

    Defined in: adventure/Game.js, line 425

    Deprecated
    • Use game.getRoom() instead.
    Convenience method to get the player's current room.
    room_lookup
    room_lookup

    Defined in: adventure/Game.js, line 238

    room_lookup stores an array containing the ids of all rooms.
    score
    score :String

    Defined in: adventure/Game.js, line 401

    Default value: ""

    Get/set game score and pass to Display.
    scorecard
    scorecard :Object

    Defined in: adventure/Game.js, line 311

    scorecard is a singleton class that stores all the game's score events and functions for managing score.
    settings
    settings :Object

    Defined in: adventure/Game.js, line 157

    settings is a singleton class that stores all the game's global settings.
    state_vars
    state_vars :Object

    Defined in: adventure/Game.js, line 98

    Default value: {}

    A place to store arbitrary game state variables, such as whether the statusbar should be hidden/shown.
    title
    title :String

    Defined in: adventure/Settings.js, line 1211

    Default value: ""

    Get/set game title and pass to Display.
    version
    version :String

    Defined in: adventure/Settings.js, line 1240

    Default value: ""

    Get/set game version and pass to Display.
    world
    world

    Defined in: adventure/Game.js, line 168

    world stores all the game asset objects. It also stores a handful of variables such as _player and _room which are used for convenience. It also stores any global vars created by the game's author. This last is done to give authors a place to store vars that can be written out with saved games.
    world._vars
    world._vars

    Defined in: adventure/Game.js, line 180

    Nested property of World

    world._vars is a namespace for authors to store any custom vars that they would like to be written out with saved games, so that they can be restored along with other saved game data in order to retain game state.
    world_lookup
    world_lookup

    Defined in: adventure/Game.js, line 215

    world_lookup stores a lookup table containing indexed keywords for all game assets.