Class:AdventureJS
Defined in: Adventure.js, line 6
Constructor:
this.AdventureJS = this.AdventureJS||{}
Description
AdventureJS is a self-invoking anonymous function that creates a container to hold the engine 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.
Engine Classes
- Atom Experimental class made with Javascript ES6 class keyword.
- Dictionary Engine 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.
- Introcard Manages the introcard for a Game instance.
- LoginManager Manage user login to adventurejs.com.
- Outrocard Manages the outrocard for a Game instance.
- Parser Interprets player input.
- 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.
- UserManager Interface for a user account logged in to adventurejs.com.
Asset Classes
- Branch Carve it, burn it, whack with it.
- Player_Can A container for state variables.
- Schmack A place to hang your coat. And hat, of course.
- Index
- Methods
- Properties
Index
Methods:
- addWorldToHistory
- arrayToLowerCase
- camelToSnake
- clone
- cloneWorld
- convertVolume
- countCommonElements
- deepSet
- denormalize
- diff
- dijkstra
- encrypt
- generateCombinations
- getBaselineDiff
- getHorizontalDistance
- getRecentAssets
- getStringArrayFunction
- getVerticalDistance
- handlePlaceholders
- hasDuplicates
- indexOfSubarray
- isFalseOrNull
- isIdInMixedArray
- isIndexInRanges
- isObfuscated
- mergeWorld
- normalize
- normalizeArray
- obfuscate
- pickRandom
- propercase
- replaceStringsWithObjects
- restoreWorld
- sentencecase
- stringToArray
- validateAssetList
- validateClassList
Properties:
Methods Collapse all |
addWorldToHistory
addWorldToHistory(world)
Defined in: adventure/utils/addWorldToHistory.js, line 4
Parameters:
-
worldObject
arrayToLowerCase
arrayToLowerCase(array) → {Array}
Defined in: adventure/utils/arrayToLowerCase.js, line 4
Parameters:
-
arrayArray
Returns:
Array
camelToSnake
camelToSnake(string) → {String}
Defined in: adventure/utils/camelToSnake.js, line 4
Parameters:
-
stringString
Returns:
String
clone
clone(source) → {Object}
Defined in: adventure/utils/clone.js, line 4
Parameters:
-
sourceObject
Returns:
Object
output
cloneWorld
cloneWorld(source) → {Object}
Defined in: adventure/utils/cloneWorld.js, line 5
Parameters:
-
sourceObject
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:
-
volumeNumber | String
In milliliters. -
context_idString
The ID of the Vessel containing the substance.
Returns:
Number
countCommonElements
countCommonElements(world) → {Number}
Defined in: adventure/utils/countCommonElements.js, line 4
Parameters:
-
worldObject
Returns:
Number
deepSet
deepSet(props, object) → {Object}
Defined in: adventure/utils/deepSet.js, line 4
Parameters:
-
propsObject
A generic object containing properties to copy to the classed object. -
objectObject
A class instance to copy properties to.
Returns:
Object
Returns the instance the method is called on (useful for chaining calls.)
denormalize
denormalize(name) → {String}
Defined in: adventure/utils/denormalize.js, line 4
Parameters:
-
nameString
Returns:
String
diff
diff(baseline_object, updated_object) → {Object}
Defined in: adventure/utils/diff.js, line 4
Parameters:
-
baseline_objectObject
Old object -
updated_objectObject
New object
Returns:
Object
dijkstra
dijkstra(graph, s) → {Object}
Defined in: adventure/utils/dijkstra.js, line 4
Parameters:
-
graphArray -
sString
Returns:
Object
encrypt
encrypt(text) → {String}
Defined in: adventure/utils/encrypt.js, line 5
Parameters:
-
textString
Returns:
String
generateCombinations
generateCombinations(world)
Defined in: adventure/utils/generateCombinations.js, line 4
Parameters:
-
worldObject
getBaselineDiff
getBaselineDiff(source_world) → {String}
Defined in: adventure/utils/getBaselineDiff.js, line 5
Parameters:
-
source_worldObject
Returns:
String
Returns a stringified diff.
getHorizontalDistance
getHorizontalDistance(point1, point2) → {Float}
Defined in: adventure/utils/getHorizontalDistance.js, line 4
Parameters:
-
point1Object -
point2Object
Returns:
Float
getRecentAssets
getRecentAssets() → {Object}
Defined in: adventure/utils/getRecentAssets.js, line 5
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. -
scopeObject
Optional reference to set scope to an object. -
paramsObject
Optional params to pass to a function.
Returns:
String
getVerticalDistance
getVerticalDistance(point1, point2) → {Float}
Defined in: adventure/utils/getVerticalDistance.js, line 4
Parameters:
-
point1Object -
point2Object
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:
-
msgString
A string on which to perform placeholder substitutions.
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.
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:
-
arrayArray -
stringString
Returns:
Boolean
indexOfSubarray
indexOfSubarray(sub, arr) → {int}
Defined in: adventure/utils/indexOfSubarray.js, line 4
Parameters:
-
subArray
0=log, 1=warn, 2=error -
arrArray
0=critical, 1=high, 2=medium, 3=low
Returns:
int
isFalseOrNull
isFalseOrNull(value) → {Boolean}
Defined in: adventure/utils/isFalseOrNull.js, line 4
Parameters:
-
value*
Returns:
Boolean
isIdInMixedArray
isIdInMixedArray(array) → {Array}
Defined in: adventure/utils/isIdInMixedArray.js, line 4
Parameters:
-
arrayArray
- convert ' ' to '_'
- convert ' and ' to '&'
- convert '.' to '$'
Returns:
Array
isIndexInRanges
isIndexInRanges(index, ranges) → {Boolean}
Defined in: adventure/utils/isIndexInRanges.js, line 6
Parameters:
-
indexInt -
rangesArray
A nested array of ranges: [[start,end]]
Returns:
Boolean
isObfuscated
isObfuscated(text) → {Boolean}
Defined in: adventure/utils/isObfuscated.js, line 5
Parameters:
-
textString
Returns:
Boolean
mergeWorld
mergeWorld(source, dest) → {Object}
Defined in: adventure/utils/mergeWorld.js, line 4
Parameters:
-
sourceObject -
destObject
Returns:
Object
dest
normalize
normalize(name) → {String}
Defined in: adventure/utils/normalize.js, line 4
Parameters:
-
nameString
Returns:
String
normalizeArray
normalizeArray(array) → {Array}
Defined in: adventure/utils/normalizeArray.js, line 4
Parameters:
-
arrayArray
Returns:
Array
obfuscate
obfuscate(text) → {String}
Defined in: adventure/utils/obfuscate.js, line 5
Parameters:
-
textString
Returns:
String
pickRandom
pickRandom(string) → {String}
Defined in: adventure/utils/pickRandom.js, line 4
Parameters:
-
stringString
Returns:
String
propercase
propercase(string) → {String}
Defined in: adventure/utils/propercase.js, line 4
Parameters:
-
stringString
Returns:
String
replaceStringsWithObjects
replaceStringsWithObjects(source, destination)
Defined in: adventure/utils/replaceStringsWithObjects.js, line 4
Parameters:
-
sourceObject -
destinationObject
restoreWorld
restoreWorld(source)
Defined in: adventure/utils/restoreWorld.js, line 5
Parameters:
-
sourceObject
sentencecase
sentencecase(string) → {String}
Defined in: adventure/utils/sentencecase.js, line 4
Parameters:
-
stringString
Returns:
String
stringToArray
stringToArray(string) → {Array}
Defined in: adventure/utils/stringToArray.js, line 4
Parameters:
-
stringString
Returns:
Array
validateAssetList
validateAssetList(property) → {Array}
Defined in: adventure/utils/validateAssetList.js, line 4
Parameters:
-
propertyString | Array
Returns:
Array
validateClassList
validateClassList(property) → {Array}
Defined in: adventure/utils/validateClassList.js, line 4
Todos: Is this unused?
Parameters:
-
propertyString | Array
Returns:
Array