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

Defined in: Adventure.js, line 5

Constructor:

this.adventurejs = this.adventurejs||{}

Description

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.
  • Game Constructs a new game object.
  • Goalcard Manages goals for a Game instance.
  • GoalManager Manages the display of the goal system.
  • Hintcard Manages hints for a Game instance.
  • HintManager Manages the display of the hint system.
  • Input Framework class, used as a property of the parser instance, that stores a turn's parsed input.
  • Introcard Manages the introcard for a Game instance.
  • LoginManager Manage user login to adventurejs.com.
  • 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.
  • Outrocard Manages the outrocard for a Game instance.
  • 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 Modern custom event system using EventTarget.
  • 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 adventurejs.com.
  • 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.
  • Axe Lockpicks can be used to pick locks.
  • Basket For carrying anything and everything.
  • 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.
  • BlackboardEraser Fixes all mistakes. Or at least the ones in pencil.
  • BladedWeapon A generic hand tool.
  • 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.
  • Cherries Some cherries.
  • 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.
  • Coin Trick or treat, give me something good to eat.
  • 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.
  • Crayon A writing implement.
  • Dagger Lockpicks can be used to pick locks.
  • Desert A base class for all kinds of containers which hold liquid.
  • 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.
  • Fruit Some kind of fruit.
  • 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.
  • Gem Trick or treat, give me something good to eat.
  • GlobalAsset Special class, parent class for global assets.
  • GlobalConcept Base class for abtract concepts such as string and number.
  • GlobalDrawing Special class to handle quoted strings in player input.
  • GlobalEnd Special class to handle "wait x minutes".
  • GlobalHour Special class to handle "wait x hours".
  • GlobalMinute Special class to handle "wait x minutes".
  • GlobalNothing Special class to handle the word 'nothing'.
  • GlobalNumber Special class to handle quoted strings in player input.
  • GlobalSomething Special class to handle the word 'something'.
  • GlobalStart Special class to handle "wait x minutes".
  • GlobalString Special class to handle quoted strings in player input.
  • GlobalTurn Special class to handle "wait x minutes".
  • GlobalUntil Special class to handle "wait x minutes".
  • GraduatedController A controller with multiple settings, like a dial.
  • GraduatedController_Is A container for state variables.
  • Grapes Some grapes.
  • Handtool A generic hand tool.
  • Hole Big enough to climb through.
  • Information A class for storing transmissible information such as passwords.
  • 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.
  • Lake A base class for all kinds of containers which hold liquid.
  • 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!
  • Meat Some kind of meat.
  • Nest A container for properties pertaining to room/player interactions.
  • NPC For non-player characters.
  • Null Special class for catching invalid calls to Game.$("asset").
  • 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.
  • Pastry Some kind of pastry.
  • Pedestal A thing on which to put other things.
  • Pen A writing implement.
  • PenCap Not the kind you wear, but the kind you attach to another thing.
  • Pencil A writing implement.
  • Phone Asset class for scanners, meaning the type used as computer peripherals.
  • Pitcher My partner will high-dive into this ordinary glass o' water.
  • Platform Useful for dividing a Room into distinct areas.
  • Player The player character.
  • Player_Can A container for state variables.
  • Plug Used to plug drains.
  • Potable Trick or treat, give me something good to eat.
  • Potion A potion to be drunk.
  • 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.
  • Reservoir A massive substance container.
  • 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.
  • Screwdriver Screwdrivers can be used to screw and unscrew.
  • Scrunchy Bringing back the man bun.
  • Shovel Lockpicks can be used to pick locks.
  • 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 This space intentionally left blank.
  • 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.
  • SubstanceEmitter_Is A container for state variables.
  • SurfaceContainer A simple base class with a surface.
  • Switch Flip the switch.
  • Sword Lockpicks can be used to pick locks.
  • 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.
  • Vegetable Some kind of vegetable.
  • Vehicle Base class for things like bicycles and skateboards.
  • Vessel Class added to an Aspect (aka aspects) to allow it to hold substances.
  • Void Special class for catching invalid calls to Game.$("asset").
  • Wall When the world slips you a Jeffrey, stroke the furry wall.
  • Whiteboard A whiteboard that can be written on and erased.
  • WhiteboardEraser Fixes all mistakes. Or at least the ones in pencil.
  • WhiteboardMarker A writing implement.
  • 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

addWorldToHistory
addWorldToHistory(world)

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

Parameters:

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

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

Parameters:

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

Returns:

Array
camelToSnake
camelToSnake(string) → {String}

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

Parameters:

  • string String
Converts a string from camelCase to snake_case.

Returns:

String
clone
clone(source) → {Object}

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

Parameters:

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

Returns:

Object output
cloneWorld
cloneWorld(source) → {Object}

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

Parameters:

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

Returns:

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

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

Todos: Handle measurements other than milliliters.

Parameters:

  • volume Number | String
    In milliliters.
  • context_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.

Returns:

Number
countCommonElements
countCommonElements(world) → {Number}

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

Parameters:

  • world Object
Count the number of common items between two comma delimited strings.

Returns:

Number
deepSet
deepSet(props, object) → {Object}

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

Parameters:

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

Returns:

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

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

Parameters:

  • name String
Reverses serialize function. Convert '_' to ' '.

Returns:

String
diff
diff(baseline_object, updated_object) → {Object}

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

Parameters:

  • baseline_object Object
    Old object
  • updated_object Object
    New object
diff function for comparing objects. Specifically intended to support UNDO and SAVE / RESTORE. It recurses objects, stringifies arrays, copies others.

Returns:

Object
dijkstra
dijkstra(graph, s) → {Object}

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

Parameters:

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

Returns:

Object
encrypt
encrypt(text) → {String}

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

Parameters:

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

Returns:

String
generateCombinations
generateCombinations(world)

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

Parameters:

  • world Object
Generate string combinations from an array of substrings.
getBaselineDiff
getBaselineDiff(source_world) → {String}

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

Parameters:

  • source_world Object
Get the diff between the baseline world state and the current world state to create a minimum data set for writing saved games.

Returns:

String Returns a stringified diff.
getHorizontalDistance
getHorizontalDistance(point1, point2) → {Float}

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

Parameters:

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

Returns:

Float
getRecentAssets
getRecentAssets() → {Object}

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

Get a list of recently referred assets. Not currently used but intended as a utility method to help with disambiguation. To use call A.getRecentAssets.call(this.game)

Returns:

Object
getStringArrayFunction
getStringArrayFunction(obj, scope, params) → {String}

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

Parameters:

  • obj *
    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.
This is an important and flexible tool in the author's quiver. Because Javascript is untyped, we can pass any kind of value in a variable. We take advantage of that to set properties that print a string back to the player using a string or an array or a function. For more information and examples, see How to Use String Array Function.

Returns:

String
getVerticalDistance
getVerticalDistance(point1, point2) → {Float}

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

Parameters:

  • point1 Object
  • point2 Object
Calculate the distance between the y of two points.

Returns:

Float
handlePlaceholders
handlePlaceholders(msg) → {String}

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

Todos: placeholders for "any key to continue" and wipe screen

Parameters:

  • msg String
    A string on which to perform placeholder substitutions.
handlePlaceholders acts on strings prior to printing them to Display. Placeholder substitution is the last step of Game.print(). It replaces placeholders, aka substrings inside {squiggly brackets}, 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 no $dollar sign: {foo}.
  • Substrings with {no dollar signs} are evaluated by adventurejs, rather than native Javascript, so they have limited scope.


  • There are several types of valid placeholders:
  • { author_variables } refers to author-created game variables that are stored within the game scope so that they can be written out to saved game files. (See Basic Scripting: Game Variables 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 MyGame.world.brown_jar.is.closed.
  • {[myclass]text} is a shortcut to <span class="myclass">text</span>, to make it easier to add custom CSS styles to text.

    AdventureJS placeholders can be mixed & matched with template literals. Placeholders 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 ${MyGame.world.aurora_door.is.closed ? "is closed, hiding the aurora. " : "is open, revealing the {northcolor} aurora light" }` } } })
  • Returns:

    String
    hasDuplicates
    hasDuplicates(array, string) → {Boolean}

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

    Parameters:

    • array Array
    • string String
    Takes an array and returns whether it contains any duplicate items.

    Returns:

    Boolean
    indexOfSubarray
    indexOfSubarray(sub, arr) → {int}

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

    Parameters:

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

    Returns:

    int
    isFalseOrNull
    isFalseOrNull(value) → {Boolean}

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

    Parameters:

    • value *
    A simple function to check whether a value is === false or null.

    Returns:

    Boolean
    isIdInMixedArray
    isIdInMixedArray(array) → {Array}

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

    Parameters:

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

    Returns:

    Array
    isIndexInRanges
    isIndexInRanges(index, ranges) → {Boolean}

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

    Parameters:

    • index Int
    • ranges Array
      A nested array of ranges: [[start,end]]
    Check if the specified index is within the provided ranges.

    Returns:

    Boolean
    isObfuscated
    isObfuscated(text) → {Boolean}

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

    Parameters:

    • text String
    Test if string is obfuscated. Our current scheme uses a character shift that converts a JSON file's leading { char to a ~ char.

    Returns:

    Boolean
    mergeWorld
    mergeWorld(source, dest) → {Object}

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

    Parameters:

    • source Object
    • dest Object
    Deep mergeWorld function for simple object types, used to merge restored save game files into baseline game state.

    Returns:

    Object dest
    obfuscate
    obfuscate(text) → {String}

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

    Parameters:

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

    Returns:

    String
    pickRandom
    pickRandom(string) → {String}

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

    Parameters:

    • string String
    Return a random item from an array of strings.

    Returns:

    String
    propercase
    propercase(string) → {String}

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

    Parameters:

    • string String
    Converts a string to Propercase (lower case with leading cap).

    Returns:

    String
    replaceStringsWithObjects
    replaceStringsWithObjects(source, destination)

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

    Parameters:

    • source Object
    • destination Object
    Replace strings in destination object with objects from source object as needed.
    restoreWorld
    restoreWorld(source)

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

    Parameters:

    • source Object
    For UNDO and RESTORE. Revert the world to the baseline snapshot and then merge in updates from a partial copy.
    sentencecase
    sentencecase(string) → {String}

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

    Parameters:

    • string String
    Capitalizes the first char of a string.

    Returns:

    String
    serialize
    serialize(name) → {String}

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

    Parameters:

    • name String
    Convert an arbitrary string to an id useable by game objects. Converts to lowercase and converts ' ' to '_'.

    Returns:

    String
    serializeArray
    serializeArray(array) → {Array}

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

    Parameters:

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

    Returns:

    Array
    stringToArray
    stringToArray(string) → {Array}

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

    Parameters:

    • string String
    Convert a string into an array containing the string.

    Returns:

    Array
    validateAssetList
    validateAssetList(property) → {Array}

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

    Parameters:

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

    Returns:

    Array
    validateClassList
    validateClassList(property) → {Array}

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

    Todos: Is this unused?

    Parameters:

    • property String | Array
    Validate a list of classes. Unused?

    Returns:

    Array

    Properties  |