Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: adventurejs

Defined in: Adventure.js, line 5

Public Constructor:

this.adventurejs = this.adventurejs||{}

adventurejs is a self-invoking anonymous function that creates a container to hold the main framework for adventure.js. adventurejs is singular and scoped to window (meaning, the browser window object), and can support simultaneous multiple Game instances. See Game for more information on constructing a Game instance.

Framework Classes

  • Asset Framework class that is the ancestor for all classes in the game world.
  • Asset_Can A container for state variables.
  • Asset_Is A container for state variables.
  • Asset_Must A container for state variables.
  • Atom Experimental class made with Javascript ES6 class keyword.
  • Dictionary Framework class that manages verb instances and lookup tables for verbs and nouns.
  • Display Manages the main game display including all related HTML elements.
  • Events Events fire at beginning / end of each turn, and can be exploited.
  • Game Constructs a new game object.
  • Input Framework class, used as a property of the parser instance, that stores a turn's parsed input.
  • LoginManager Manage user login to
  • NounMustBe Framework class, used as a property of a verb instance, that sets conditions a noun must meet for the verb to act on it.
  • ParsedNoun Special class used to store metadata about an asset and lists of all possible matches for that asset.
  • Parser Interprets player input.
  • Phrase Special class used to identify nouns that a verb can act on.
  • Reactor Manages event listening for custom events.
  • RestoreManager Manages the process of restoring saved games.
  • SaveManager Manages the process of saving games.
  • Scorecard Manages score for a Game instance.
  • Settings Manages settings for a Game instance.
  • StateManager A container for state variables.
  • SubstanceMixer Shaken, not stirred.
  • UID Generates sequential unique ID numbers.
  • UserManager Interface for a user account logged in to
  • Verb Framework class that all verbs are instanced from.
  • VerbSubscription A standardized format for attaching verb subscriptions to assets.

Asset Classes

  • All Internal class used to help parse when player inputs "all".
  • Aperture Base class for doors, windows, and other passageways.
  • Aperture_Is A container for state variables.
  • Aspect Class that allows putting things in/on/under/behind/attached.
  • Aspect_Player A container for properties pertaining to room/player interactions.
  • Bathtub Rub a dub dub.
  • Bed Zzzzzzzbuhbuhbuhbuhbuhzzzzz.
  • Bicycle I want to ride my bicycle I want to ride my bike.
  • Binoculars Curse this blasted balcony seat.
  • Blackboard A blackboard that can be written on and erased.
  • Bowl Waiter, there's a fly in my soup!
  • Branch Carve it, burn it, whack with it.
  • Button Please don't press this button again.
  • Candle Asset class for a candle that can be lit and provide light.
  • Cap Not the kind you wear, but the kind you attach to another thing.
  • Ceiling Look up.
  • Chair For sitting.
  • Chalice You have chosen wisely.
  • Chalk A writing implement.
  • Character Base class for all character types.
  • Character_Can A container for state variables.
  • Character_Is A container for state variables.
  • Character_Must A container for state variables.
  • Chest Maybe there's gold inside! Arg a trap!
  • Climbable Players can climb it.
  • ClimbableVine A hanging vine that player can climb.
  • Clothing Clothes make the [wo]man.
  • Coathook A place to hang your hat. And coat, of course.
  • Coatrack A place to hang your coat. And hat, of course.
  • Coinpurse A place for your arcade tokens.
  • Collection An Asset that provides a way to refer to a group of Assets together.
  • Computer Asset class for computers, including desktops and laptops and Landru.
  • Container Thing to put things in.
  • Control Base class for controls of all kinds.
  • Desk Get back to work!
  • Dial Turn turn turn.
  • Doll Not the kind you wear, but the kind you attach to another thing.
  • Door Shut the door!
  • Drain Roto Rooter, that's the name, to send your troubles down the drain.
  • Drainable Ancestor class for Sinks and Bathtubs.
  • Drainable_Is A container for state variables.
  • Drawer Like you'd find in a desk.
  • DrinkingGlass My partner will high-dive into this ordinary glass o' water.
  • DrinkingMug A place for your coffee.
  • Edible Trick or treat, give me something good to eat.
  • Electronics Use to create things player can tie rope to and swing from.
  • Eraser Fixes all mistakes. Or at least the ones in pencil.
  • Exit Makes travel between Rooms possible.
  • Exit_Is A container for state variables.
  • Extrusion Use to create things player can tie rope to and swing from.
  • ExtrusionBranch A branch that player can tie rope to and swing from.
  • EyeGlasses Blast! These aren't my cheaters!
  • Faucet Faucet is a SubstanceEmitter that can generate liquid.
  • FaucetHandle A handle that can be turned by degrees.
  • Floor Catches player input such as pour water on floor.
  • FloorChasm A chasm or gap or pit in the floor.
  • Furniture A base class for all kinds of furniture.
  • Gas Base class for Gas Substances, like helium.
  • GasContainer For propane tanks, helium tanks, and the like.
  • Gauge A tool of measurement.
  • GlobalAsset Special class, parent class for global assets.
  • GlobalNothing Special class to handle the word 'nothing'.
  • GlobalSomething Special class to handle the word 'something'.
  • GlobalString Special class to handle quoted strings in player input.
  • GraduatedController A controller with multiple settings, like a dial.
  • Hole Big enough to climb through.
  • Intangible Base class for abtract objects with no physical presence.
  • Key Keys unlock locks.
  • Keyboard A computer keyboard that players can type on.
  • Knapsack For carrying your schoolbooks.
  • Ladder It's bad luck to walk under it.
  • Lantern Asset class for a lantern that can be lit and provide light.
  • Lever Pull the lever!
  • Liquid Base class for liquids. Has properties of water.
  • LiquidContainer A base class for all kinds of containers which hold liquid.
  • Lockpick Lockpicks can be used to pick locks.
  • Luggage A base class for all kinds of luggage.
  • Manhole Best game of 1988. I just downloaded a copy for iOS!
  • Marker A writing implement.
  • Matter Let's get physical! Physical!
  • NPC For non-player characters.
  • OpticalDevice Base class for EyeGlass, Binocular, Telescope, etc.
  • Outlet An electrical outlet.
  • Paper A sheet of paper that can be typed on or written on.
  • PaperMoney A piece of paper money.
  • Pedestal A thing on which to put other things.
  • Pen A writing implement.
  • PenCap A cap for a pen.
  • Pencil A writing implement.
  • Phone Asset class for scanners, meaning the type used as computer peripherals.
  • Platform Useful for dividing a Room into distinct areas.
  • Player The player character.
  • Plug Used to plug drains.
  • Potion Thing to put things in.
  • Printer Asset class for printers, meaning the type used as computer peripherals.
  • Purse For carrying anything and everything.
  • Radio Asset class for radios, including desktops, handhelds, and car.
  • Rideable Base class for things like bicycles and skateboards.
  • Room Where all the action happens.
  • Rope Tie to things, tie things to other things.
  • Scanner Asset class for scanners, meaning the type used as computer peripherals.
  • Scenery Stop and smell the roses.
  • Schmack A place to hang your coat. And hat, of course.
  • Screen A screen that can display strings input on a Keyboard.
  • Scrunchy Bringing back the man bun.
  • SingleUseKey A single use key can unlock a lock. Once.
  • SingleUseLockpick A single use lockpick can be used to pick a lock. Once.
  • Sink For bathrooms and kitchens.
  • Skateboard Whoa, that's a gnarly deck, dude.
  • SkeletonKey SkeletonKeys can be used to unlock...anything?
  • Sky A scenery Asset.
  • Slurry Base class for Slurry Substances, like mud.
  • Solid Base class for Solid Substances, like dirt.
  • SolidContainer A container for solid substances.
  • Spell _
  • Staircase A stairway to heaven?
  • Stalactite It clings tight to the ceiling.
  • StationaryTelescope You LOVE the Plane-arium.
  • Substance Solids, Liquids, Slurries, and Gasses, baby.
  • Substance_Is A container for state variables.
  • SubstanceEmitter Generates a specified substance, in specified quantity per turn.
  • SurfaceContainer A simple base class with a surface.
  • Switch Flip the switch.
  • Table Time for din-din!
  • Tangible Base class for all game objects with physical properties.
  • Tangible_Can A container for state variables.
  • Tangible_Is A container for state variables.
  • Tangible_Must A container for state variables.
  • Telescope Curse this blasted balcony seat.
  • Thing Base class for most things with physical properties.
  • Tree One grows in Brooklyn.
  • Tub A non-interactive tub.
  • Typewriter A typewriter that players can type on.
  • Vessel Class added to an Aspect (aka aspects) to allow it to hold substances.
  • Wall When the world slips you a Jeffrey, stroke the furry wall.
  • Whiteboard A whiteboard that can be written on and erased.
  • Window You make a better door than a window.
  • WritingImplement Generic base class for pens, pencils and the like.
  • WritingSurface A surface that can be written on and erased.
  • Zone Set UniversalScenery descriptions for groups of Rooms.
Inherited Overrides

Methods Collapse all  |  Expand all


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


  • world Object
Save the current world state for UNDO.
arrayToLowerCase(array) → {Array}

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


  • array Array
Takes an array of strings, converts them to lowercase, and returns the array.


clone(source) → {Object}

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


  • source Object
A deep clone function for simple object types.


Object output
cloneWorld(source) → {Object}

Defined in: adventure/utils/cloneWorld.js, line 6


  • source Object
Clone the game world for save / restore functions.


Object Returns a copy of the source world.
convertVolume(volume, parent_id) → {Number}

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

Todos: Handle measurements other than milliliters.


  • volume Number | String
    In milliliters.
  • parent_id String
    The ID of the Vessel containing the substance.
Converts a string or number into milliliters. Accepts a number representing volume in milliliters, or a string to be converted to milliliters (ex: "100ml"), in nL, μL, mL, cL, dL, L, daL, hL, kL, ML.


deepSet(props, object) → {Object}

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


  • props Object
    A generic object containing properties to copy to the classed object.
  • object Object
    A class instance to copy properties to.
This is a deep copy method used for assets and verbs. Returns the object being set for chaining.


Object Returns the instance the method is called on (useful for chaining calls.)
deserialize(name) → {String}

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


  • name String
Reverses serialize function.
  • convert '_' to ' '
  • convert '&' to ' and '
  • convert '$' to '.'


dijkstra(graph, s) → {Object}

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


  • graph Array
  • s String
A pathfinding function used to determine whether travel between two given locations is possible. Based on Dijkstra's algorithm, specifically adapted from jpillora's dijkstra.js.


getHorizontalDistance(point1, point2) → {Float}

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


  • point1 Object
  • point2 Object
Calculate the distance between two x/z points.


getStringOrArrayOrFunction(obj, scope, params) → {String}

Defined in: adventure/utils/getStringOrArrayOrFunction.js, line 6


  • obj String | Array | function | Boolean | null
    Can be string or array or function.
  • scope Object
    Optional reference to set scope to an object.
  • params Object
    Optional params to pass to a function.

Get string or array or function. Because Javascript is untyped, we can pass any kind of value in a variable. We take advantage of that here to provide flexibility to authors in properties that print a string back to the player.

  • Strings will be printed as is.
  • Arrays can be set to provide a string from a randomized index, or a sequential index that increments each time it's called.
  • Functions can use their own internal logic to return a string, allowing for dynamic state-based descriptions, such as whether an Asset is open or closed.


  class: "Desk",
  name: "desk",
  descriptions: { look: "An old school wooden desk. ", },
  class: "Drawer",
  name: "drawer",
  descriptions: {
    look: function(){
      return "The drawer is $( drawer is| open or| closed ). ";
  class: "Blotter",
  name: "blotter",
  descriptions: {
    look: [
      {randomize: true},
      "The words 'live and let die' are scrawled on the blotter. ",
      "The desk blotter has 'born to bleed' carved into it. ",
      "You see 'zep rulez!' scratched in to the desk blotter. ",

For more information, see How to Use String|Array|Function.

Properties that call getStringOrArrayOrFunction

  • verb subscription on_success: asset.[i|d]ov[verb].on_success
  • verb subscription then_destroy: asset.[i|d]ov[verb].then_destroy
  • all descriptions: asset.description and asset.descriptions[any]
  • room events: room.room_events
  • zone events:
  • custom vars:[ property ]
  • constraint message: character.constrained_msg


indexOfSubarray(sub, arr) → {int}

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


  • sub Array
    0=log, 1=warn, 2=error
  • arr Array
    0=critical, 1=high, 2=medium, 3=low
Determine if one array is nested in another.


serialize(name) → {String}

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


  • name String
Convert an arbitrary string to an id useable by game objects.
  • convert ' ' to '_'
  • convert ' and ' to '&'
  • convert '.' to '$'


serializeArray(array) → {Array}

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


  • array Array
Convert an array of arbitrary strings to an array of IDs useable by game objects.
  • convert ' ' to '_'
  • convert ' and ' to '&'
  • convert '.' to '$'


substituteCustomTemplates(msg) → {String}

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

Todos: update classdesc


  • msg String
    A string on which to perform substitutions.
substituteCustomTemplates acts on strings prior to printing them to Display. Substitution is the last step of Game.print(). It replaces custom templates, aka substrings bracketed inside parentheses, like $(door is| open or| closed).

For example:
descriptions: { look: "The drawer is $( drawer is| open or| closed )." }

This method is similar to Javascript ES6 template literals but with important distinctions.
  • The adventurejs version uses different symbols: $(parentheses) instead of Javascript's native ${curly braces}.
  • Substrings inside $(parens) are evaluated by adventurejs, rather than native Javascript, so they have limited scope.

  • There are several types of valid substitutions:
  • $( author_variables ) refers to author-created custom variables that are stored within the game scope so that they can be written out to saved game files. (See How to Use Custom Vars for more info.)
  • $( asset is| state or| unstate ) allows authors to refer to a game asset by name or id and print certain verb states. Names are serialized during the substitution process, meaning that, for example: $( brown jar is| open or| closed ) will be interpreted to check for
  • $(tag|text) is a shortcut to <span class="tag">text</span>, to make it easier to add custom CSS styles to text.

    Adventurejs custom templates can be mixed & matched with template literals. Custom templates can be used in any string that outputs to the game display. However, because template literals in strings are evaluated when the properties containing them are created, they will cause errors on game startup. In order to use native Javascript template literals, they must be returned by functions. MyGame.createAsset({ class: "Room", name: "Standing Room", descriptions: { brief: "The north door is $(north is| open or| closed). ", through: "Through the door you see a $(northcolor) light. ", verbose: return function(){ `The north door ${ ? "is closed, hiding the aurora. " : "is open, revealing the $(northcolor) aurora light" }` } } })
  • Returns:

    validateAssetList(property) → {Array}

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


    • property String | Array
    Serialize asset names in an array. Asset names may be nested inside objects in the array. A secondary effect of this function is that it converts object properties from strings to arrays, which corrects for cases of authors providing strings for properties that want arrays. For example: "skeleton key" would be converted to ["skeleton_key"].



    Properties  |