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

Defined in: Adventure/Input.js, line 5

Engine class

Description

Input is a special class constructed by Parser.parseInput(), and used to store each turn's input and all of the metadata that is generated for it, including the verb and noun(s) that were parsed, whether a disambiguation was called for, whether a soft prompt was made, whether a noun was inferred based upon context, and other data. This is an internal class that authors should not need to construct.

Private Constructor:

var foo = new AdventureJS.Parser.Input()
Inherited Overrides

Methods Collapse all  |  Expand all

appendOutput
appendOutput(msg) → {boolean}

Defined in: Adventure/Input.js, line 405

appendOutput

Parameters:

  • msg String
    Arbitrary string to append to next print.
Lets author append an arbitrary string to this turn's output.

Returns:

boolean
deletePhrase
deletePhrase(index)

Defined in: Adventure/Input.js, line 420

Parameters:

  • index int
Delete the specified phrase in the verified sentence and renumber any higher numbered phrases.
getAdverb
getAdverb() → {String}

Defined in: Adventure/Input.js, line 441

Try to get an adverb from the verb in the verified sentence.

Returns:

String
getAsset
getAsset(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 456

Parameters:

  • index int
Try to get an asset from the parsedNoun in the specified phrase in the verified sentence.

Returns:

Object | Boolean
getAssets
getAssets() → {Array}

Defined in: Adventure/Input.js, line 483

Get any assets referenced in all phrases.

Returns:

Array
getContainerAsset
getContainerAsset(index)

Defined in: Adventure/Input.js, line 518

Parameters:

  • index Int
When player refers to a substance, some verbs will try to identify a vessel containing that substance. Get that container asset.
getDictionaryVerb
getDictionaryVerb(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 530

Parameters:

  • index int
Get dictionary verb from the verified sentence.

Returns:

Object | Boolean
getDirection
getDirection(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 547

Parameters:

  • index int
Try to get a direction from the verified sentence.

Returns:

Object | Boolean
getExclusion
getExclusion(index) → {String|Boolean}

Defined in: Adventure/Input.js, line 558

Parameters:

  • index int
Try to get an exclusion string from the verified sentence.

Returns:

String | Boolean
getInferred
getInferred(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 569

Parameters:

  • index int
Ask if verified noun has been set inferred.

Returns:

Object | Boolean
getInPhrase
getInPhrase(position, property) → {*}

Defined in: Adventure/Input.js, line 580

Parameters:

  • position String
  • property String
Try to get a property from the specified phrase.

Returns:

*
getInput
getInput()

Defined in: Adventure/Input.js, line 598

Get the source input for this turn, accounting for soft prompt responses that update last turn's input.
getNoun
getNoun(index) → {String|Boolean}

Defined in: Adventure/Input.js, line 635

Parameters:

  • index int
Try to get a noun string from the verified sentence.

Returns:

String | Boolean
getNounCount
getNounCount() → {int}

Defined in: Adventure/Input.js, line 646

Get a count of nouns.

Returns:

int
getParam
getParam(param) → {*}

Defined in: Adventure/Input.js, line 812

Parameters:

  • param String
Get a verb parameter. If a comparator is provided, will test if param value is equivalent and return a boolean. If no comparator is provided, will return the value of the param.

Returns:

*
getParsedNoun
getParsedNoun(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 666

Parameters:

  • index int
Try to get a parsedNoun in the specified phrase in the verified sentence.

Returns:

Object | Boolean
getPhrase
getPhrase(index) → {Object}

Defined in: Adventure/Input.js, line 724

Parameters:

  • index int
Get the specified phrase from the verified sentence.

Returns:

Object
getPhraseCount
getPhraseCount()

Defined in: Adventure/Input.js, line 678

Get the number of phrases in the input.
getPlatonic
getPlatonic(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 692

Parameters:

  • index int
Try to get a platonic asset from the parsedNoun in the specified phrase in the verified sentence.

Returns:

Object | Boolean
getPreposition
getPreposition(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 736

Parameters:

  • index int
Try to get a preposition from the verified sentence.

Returns:

Object | Boolean
getStructure
getStructure()

Defined in: Adventure/Input.js, line 747

Todos: replace with verified sentence structure

Returns the parsed sentence structure.
getStructure
getStructure(value) → {boolean}

Defined in: Adventure/Input.js, line 853

Todos: replace with verified sentence structure

Parameters:

  • value String
Returns the parsed sentence structure.

Returns:

boolean
getSubject
getSubject() → {*}

Defined in: Adventure/Input.js, line 757

The subject that this turn applies to. By default, this will be the player. In the case of input such as "Claude, go east", target will be the specified NPC.

Returns:

*
getSubstance
getSubstance(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 770

Parameters:

  • index int
Try to get a substance asset from the parsedNoun in the specified phrase in the verified sentence.

Returns:

Object | Boolean
getVerb
getVerb(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 796

Parameters:

  • index int
Get verb from the verified sentence.

Returns:

Object | Boolean
hasInput
hasInput() → {Boolean}

Defined in: Adventure/Input.js, line 830

Does the input object have verified input?

Returns:

Boolean
hasPhrase
hasPhrase(index) → {Boolean}

Defined in: Adventure/Input.js, line 841

Parameters:

  • index int
Does the specified phrase exist in the verified sentence?

Returns:

Boolean
hasVerb
hasVerb(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 865

Parameters:

  • index int
Get verb from the verified sentence.

Returns:

Object | Boolean
isObject
isObject() → {*}

Defined in: Adventure/Input.js, line 881

Ask whether the specified id is an object of the turn.

Returns:

*
overrideOutput
overrideOutput(msg) → {boolean}

Defined in: Adventure/Input.js, line 891

overrideOutput

Parameters:

  • msg String
    Arbitrary string to override next print.
Lets author override this turn's output.

Returns:

boolean
prependOutput
prependOutput(msg) → {boolean}

Defined in: Adventure/Input.js, line 906

prependOutput

Parameters:

  • msg String
    Arbitrary string to prepend to next print.
Lets author prepend an arbitrary string to this turn's output.

Returns:

boolean
printOutput
printOutput() → {boolean}

Defined in: Adventure/Input.js, line 921

printOutput

Print this game's turn.

Returns:

boolean
pushParsedWord
pushParsedWord(params)

Defined in: Adventure/Input.js, line 935

Parameters:

  • params Object
Push a parsed word to parsed_sentence.
pushPhrase
pushPhrase(params) → {Int}

Defined in: Adventure/Input.js, line 945

Parameters:

  • params Object
Add a new phrase at the lowest available phrase number. Inferred is always true.

Returns:

Int
pushViewModifiers
pushViewModifiers(identifier, asset, type)

Defined in: Adventure/Input.js, line 979

Parameters:

  • identifier String
    aka aspect or preposition or description
  • asset Object
    can be null
  • type String
    auto or input
Push asset to view_modifiers for use with customized asset descriptions.
setAdverb
setAdverb() → {String}

Defined in: Adventure/Input.js, line 1013

Set an adverb for the verb in the verified sentence.

Returns:

String
setAsset
setAsset(index, parsedNoun)

Defined in: Adventure/Input.js, line 1027

Parameters:

  • index Int
  • parsedNoun Object
Set the asset in the specified phrase. Asset means Asset-classed object, but we store here a ParsedNoun which is its own classed object that includes metadata about the Asset object. If asset is a string, try to get the object. If asset is a direction string, try to get an exit.
setContainer
setContainer(index)

Defined in: Adventure/Input.js, line 506

Parameters:

  • index Int
When player refers to a substance, some verbs will try to identify a vessel containing that substance. Get that vessel id.
setContainer
setContainer(index, asset)

Defined in: Adventure/Input.js, line 1056

Parameters:

  • index Int
  • asset Object
When player refers to a substance, some verbs will try to identify a vessel containing that substance. Save that vessel id here.
setDirection
setDirection(index, value)

Defined in: Adventure/Input.js, line 1089

Parameters:

  • index int
  • value Object
Set verified direction.
setDisambiguate
setDisambiguate(params)

Defined in: Adventure/Input.js, line 1100

Parameters:

  • params Object
Indicate that this turn parsed one word, which may satisfy a disambiguation prompt.
setExclusion
setExclusion(index, value) → {String|Boolean}

Defined in: Adventure/Input.js, line 1114

Parameters:

  • index int
  • value String
Set an exclusion string in the verified sentence.

Returns:

String | Boolean
setInferred
setInferred(index) → {Object|Boolean}

Defined in: Adventure/Input.js, line 1126

Parameters:

  • index int
Set verified noun inferred.

Returns:

Object | Boolean
setInPhrase
setInPhrase(position, property) → {*}

Defined in: Adventure/Input.js, line 1138

Parameters:

  • position String
  • property String
Try to get a property from the specified phrase.

Returns:

*
setNoun
setNoun(index, value) → {String|Boolean}

Defined in: Adventure/Input.js, line 1153

Parameters:

  • index int
  • value String
Set a noun string from the verified sentence. Be careful to avoid letting noun and parsedNoun fall out of sync. By contrast, setAsset() will set both noun and parsedNoun.

Returns:

String | Boolean
setOneWord
setOneWord(params)

Defined in: Adventure/Input.js, line 1169

Parameters:

  • params Object
Indicate that this turn parsed one word, which may satisfy a disambiguation prompt.
setParam
setParam(param, value)

Defined in: Adventure/Input.js, line 1296

Parameters:

  • param String
  • value *
Set a verb parameter.
setParsedNoun
setParsedNoun(index, parsedNoun)

Defined in: Adventure/Input.js, line 1183

Parameters:

  • index int
  • parsedNoun Object
Set a parsedNoun in the specified phrase in the verified sentence.
setParsedNoun
setParsedNoun(index, parsedNoun)

Defined in: Adventure/Input.js, line 1195

Parameters:

  • index int
  • parsedNoun Object
Set a parsedNoun in the specified phrase in the verified sentence.
setPhrase
setPhrase(index, type, value)

Defined in: Adventure/Input.js, line 1213

Parameters:

  • index int
  • type string
  • value string
Set the specified phrase in the verified sentence.
setPreposition
setPreposition(index, value)

Defined in: Adventure/Input.js, line 1228

Parameters:

  • index int
  • value string
Set verified preposition.
setSoftPrompt
setSoftPrompt(params)

Defined in: Adventure/Input.js, line 1239

Parameters:

  • params Object
Set a soft prompt for next turn.
setStructure
setStructure()

Defined in: Adventure/Input.js, line 1270

Todos: replace with verified sentence structure

Set the parsed sentence structure.
setSubject
setSubject()

Defined in: Adventure/Input.js, line 1255

The subject that this turn applies to. By default, this will be the player. In the case of input such as "Claude, go east", target will be the specified NPC.
setVerb
setVerb(value)

Defined in: Adventure/Input.js, line 1280

Parameters:

  • value String
Set the specified verb in the verified sentence. We're only ever taking one verb, but provisioning for more in the future in the case of structures such as "tell person to go north".
shiftPhrase
shiftPhrase(params) → {Int}

Defined in: Adventure/Input.js, line 1307

Parameters:

  • params Object
Insert a new phrase at beginning of sentence structure. Inferred is always true.

Returns:

Int
swapNouns
swapNouns(index1, index2) → {Object|Boolean}

Defined in: Adventure/Input.js, line 1336

Parameters:

  • index1 int
  • index2 int
Swap two nouns

Returns:

Object | Boolean
swapPhrases
swapPhrases(index1, index2) → {Object|Boolean}

Defined in: Adventure/Input.js, line 1361

Parameters:

  • index1 int
  • index2 int
Swap two phrases

Returns:

Object | Boolean
swapPrepositions
swapPrepositions(index1, index2) → {Object|Boolean}

Defined in: Adventure/Input.js, line 1379

Parameters:

  • index1 int
  • index2 int
Swap two prepositions

Returns:

Object | Boolean
updateStructure
updateStructure()

Defined in: Adventure/Input.js, line 1394

Reset the verified sentence structure (after revising verified_sentence).

Properties  | 

allow_circular_verb
allow_circular_verb :Boolean

Defined in: Adventure/Input.js, line 269

Default value: false

Todos: Should this also be an Array and sync indexes with verb_chain?

In some instances we want to allow a verb to be reused, such as when we're redirecting between nouns rather than verbs.
asked_politely
asked_politely :String

Defined in: Adventure/Input.js, line 211

Default value: undefined

Set true if player used "please" or "I want to" or "I want you to".
did.doAfterSuccess
did.doAfterSuccess :Boolean

Defined in: Adventure/Input.js, line 368

Default value: false

Nested property of Did

did.doAfterTry
did.doAfterTry :Boolean

Defined in: Adventure/Input.js, line 356

Default value: false

Nested property of Did

did.doBeforeSuccess
did.doBeforeSuccess :Boolean

Defined in: Adventure/Input.js, line 362

Default value: false

Nested property of Did

did.doBeforeTry
did.doBeforeTry :Boolean

Defined in: Adventure/Input.js, line 344

Default value: false

Nested property of Did

did.doSuccess
did.doSuccess :Boolean

Defined in: Adventure/Input.js, line 336

Default value: false

Nested property of Did

Set when one verb calls another verb via dictionary.doVerb(), so that the wrapping verb performs a minimal doSuccess.
did.doTry
did.doTry :Boolean

Defined in: Adventure/Input.js, line 350

Default value: false

Nested property of Did

did.phases
did.phases :Boolean

Defined in: Adventure/Input.js, line 374

Default value: []

Nested property of Did

did.print
did.print :Boolean

Defined in: Adventure/Input.js, line 380

Default value: false

Nested property of Did

did.tryTravel
did.tryTravel :Boolean

Defined in: Adventure/Input.js, line 386

Default value: false

Nested property of Did

Set when a verb calls tryTravel() - which has its own success methods - so that the calling verb performs a minimal doSuccess.
disambiguate
disambiguate :int

Defined in: Adventure/Input.js, line 244

Default value: { 'index':null, 'noun1':false, 'noun2':false, 'noun3':false }

When we call for disambiguation, we ask for noun1, noun2, or noun3. We save the index here so we can refer to, for ex: "disambiguate["noun"+disambiguate.index].
found_word
found_word :String

Defined in: Adventure/Input.js, line 171

Default value: ""

If player only input one word, store that here, because we parse single words differently from multiple words.
game
game :Getter

Defined in: Adventure/Input.js, line 396

Getter function that returns the top level game object. Use this.game.
input
input :String

Defined in: Adventure/Input.js, line 49

Default value: ""

Save the normalized input string for later reference. This is updated per queued action, so for instance if player inputs "take knife then go north" each turn will print input as "> take knife" and "> go north"
input_verb
input_verb :String

Defined in: Adventure/Input.js, line 179

Default value: ""

A string containing the id of the verb that was found in player input. Verb id may differ from actual input. For example, "plug in" results in "plugIn".
is_command
is_command :Object

Defined in: Adventure/Input.js, line 42

Default value: {}

Whether a command was issued to an NPC.
original_input
original_input :String

Defined in: Adventure/Input.js, line 79

Deprecated
  • Yes

Default value: ""

Save the original unedited input string for later reference. Does not account for input that is broken into queued actions so for instance if player inputs "take knife then go north" this will remain unchanged for queued actions.
output_class
output_class :String

Defined in: Adventure/Input.js, line 163

Default value: ""

Optional string containing a space delimited list of CSS classes to apply to the printed output.
parsed_input
parsed_input :String

Defined in: Adventure/Input.js, line 59

Save the parsed input string for later reference. This is updated per queued action, so for instance if player inputs "take knife then go north" each turn will print input as "> take knife" and "> go north"
parsed_sentence
parsed_sentence :Array

Defined in: Adventure/Input.js, line 114

Default value: []

We use this as an intermediary step to store the parsed, typed input before we verify it.
parsed_word
parsed_word :Array

Defined in: Adventure/Input.js, line 106

Default value: { 'enabled':false }

Property used by handleWord() to pass data to parseMultipleInputs().
parsedNoun1
parsedNoun1 :Getter|Setter

Defined in: Adventure/Input.js, line 1450

A bridge between the old and new input systems. A parsed noun object for the first noun found in player input.
parsedNoun1_is_assumed
parsedNoun1_is_assumed :Getter|Setter

Defined in: Adventure/Input.js, line 1483

A bridge between the old and new input systems. Player did not input a noun, but we extrapolated one from context.
parsedNoun2
parsedNoun2 :Getter|Setter

Defined in: Adventure/Input.js, line 1461

A bridge between the old and new input systems.
parsedNoun2_is_assumed
parsedNoun2_is_assumed :Getter|Setter

Defined in: Adventure/Input.js, line 1495

A bridge between the old and new input systems. Player did not input a noun, but we extrapolated one from context.
parsedNoun3
parsedNoun3 :Getter|Setter

Defined in: Adventure/Input.js, line 1472

A bridge between the old and new input systems.
parsedNoun3_is_assumed
parsedNoun3_is_assumed :Getter|Setter

Defined in: Adventure/Input.js, line 1507

A bridge between the old and new input systems. Player did not input a noun, but we extrapolated one from context.
points
points :Array

Defined in: Adventure/Input.js, line 304

Default value: []

If player is awarded points for this turn, we save the point id(s) here.
preposition1
preposition1 :Getter|Setter

Defined in: Adventure/Input.js, line 1417

A bridge between the old and new input systems.
preposition2
preposition2 :Getter|Setter

Defined in: Adventure/Input.js, line 1428

A temporary bridge between the old and new input systems.
preposition3
preposition3 :Getter|Setter

Defined in: Adventure/Input.js, line 1439

A temporary bridge between the old and new input systems.
printer
printer :Object

Defined in: Adventure/Input.js, line 133

Default value: { output:"", append:[], prepend:[], override:[], appended:[], prepended:[], overridden:[] }

Object for managing strings that author appends/overrides/prepends to native output.
raw_input
raw_input :String

Defined in: Adventure/Input.js, line 69

Default value: ""

The player's original unparsed input string. Does not account for input that is broken into queued actions so for instance if player inputs "take knife then go north" this will remain unchanged for queued actions.
soft_prompt
soft_prompt :Boolean

Defined in: Adventure/Input.js, line 218

Default value: { 'verb':null, 'noun1':false, 'noun2':false, 'noun3':false, 'enabled':false, 'satisfied':false }

We're making a soft prompt with this turn, asking for clarification of a verb or noun.
strings
strings :Array

Defined in: Adventure/Input.js, line 295

Default value: []

If player inputs quoted strings, we save them here. Ex: 'type "foo" on typewriter', we save "foo" as an unparsed string.
target
target :Object

Defined in: Adventure/Input.js, line 33

Default value: {}

By default, subject is player. If input is found to be an NPC directive, such as "Floyd, go east", subject will be set to NPC.
tokens
tokens :Object

Defined in: Adventure/Input.js, line 287

Default value: {}

During parsing we convert some substrings to tokens. Here we keep a record of the source substrings.
travel
travel :Object

Defined in: Adventure/Input.js, line 149

Default value: {}

Object for managing travel within turns.
unknown_word
unknown_word :String

Defined in: Adventure/Input.js, line 204

Default value: undefined

If parser found an unknown word, store it here.
verb_chain
verb_chain :Array

Defined in: Adventure/Input.js, line 260

Default value: []

It's possible to redirect from one verb to another within a single turn. We save each verb's id in verb_chain, to check that we're not stuck in a circular loop.
verb_params
verb_params :Object

Defined in: Adventure/Input.js, line 278

Default value: {}

A method for passing arbitrary properties along with a verb redirect. For ex: close_with may redirect to lock_with, and we may want to pass a param such as "autoClose=true".
verb_phrasal_pattern
verb_phrasal_pattern :Array

Defined in: Adventure/Input.js, line 311

Default value: []

During parse we perform regex to identify phrasal verbs. For example, if player inputs "write name on paper with pencil", tokenizeVerbNounPrepNounPrepNouns() would find "write_on_with paper pencil". We save the phrasal verb for use in verb logic.
verb_phrase
verb_phrase :String

Defined in: Adventure/Input.js, line 188

Default value: ""

The verb and its associated prepositions. For example "jump from root to branch" would result in "jump from to".
verb_phrase_prepositions
verb_phrase_prepositions :String

Defined in: Adventure/Input.js, line 196

Default value: ""

Just the prepositions of the phrasal verb. For example "jump from root to branch" would result in "from to".
verified_sentence
verified_sentence :Object

Defined in: Adventure/Input.js, line 90

Default value: {}

The end result of parsing is a set of verified words - verbs, nouns and prepositions - which can be used by verbs.
verified_sentence_structure
verified_sentence_structure :Array

Defined in: Adventure/Input.js, line 122

Default value: ""

This is a simple representation of the parsed input for comparison purposes. Verbs may have their accepts_structures property set to a list of valid sentence structures. This gives us another way to validate input, by comparing it to a verb's capabilities.
view_modifiers
view_modifiers :Object

Defined in: Adventure/Input.js, line 98

Default value: []

An array of assets that may be used to modify asset descriptions, such as viewports, viewpoints, light sources.
was_split
was_split :Boolean

Defined in: Adventure/Input.js, line 156

Default value: false

Whether the input was split.