Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0

Class: Input

Defined in: adventure/Input.js, line 6

Framework class

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 assumed based upon context, and other data. This is an internal class that authors should not need to construct.

Private Constructor:

var foo = new adventurejs.Input()
Inherited Overrides

Methods Collapse all  |  Expand all

appendToOutput(msg) → {boolean}

Defined in: adventure/Input.js, line 246

Parameters:

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

Returns:

boolean
deletePhrase(index)

Defined in: adventure/Input.js, line 365

Parameters:

  • index int
Delete the specified phrase in the verified sentence and renumber any higher numbered phrases.
getAsset(index) → {Object|Boolean}

Defined in: adventure/Input.js, line 499

Parameters:

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

Returns:

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

Defined in: adventure/Input.js, line 701

Parameters:

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

Returns:

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

Defined in: adventure/Input.js, line 317

Parameters:

  • index int
Get dictionary verb from the verified sentence.

Returns:

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

Defined in: adventure/Input.js, line 637

Parameters:

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

Returns:

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

Defined in: adventure/Input.js, line 476

Parameters:

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

Returns:

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

Defined in: adventure/Input.js, line 781

Parameters:

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

Returns:

*
getNoun(index) → {String|Boolean}

Defined in: adventure/Input.js, line 449

Parameters:

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

Returns:

String | Boolean
getNounCount() → {int}

Defined in: adventure/Input.js, line 417

Get a count of nouns.

Returns:

int
getParsedNoun(index) → {Object|Boolean}

Defined in: adventure/Input.js, line 659

Parameters:

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

Returns:

Object | Boolean
getPhrase(index) → {Object}

Defined in: adventure/Input.js, line 405

Parameters:

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

Returns:

Object
getPhraseCount()

Defined in: adventure/Input.js, line 601

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

Defined in: adventure/Input.js, line 615

Parameters:

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

Returns:

Object | Boolean
getStructure()

Defined in: adventure/Input.js, line 867

Todos: replace with verified sentence structure

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

Defined in: adventure/Input.js, line 887

Todos: replace with verified sentence structure

Parameters:

  • value String
Returns the parsed sentence structure.

Returns:

boolean
getVerb(index) → {Object|Boolean}

Defined in: adventure/Input.js, line 301

Parameters:

  • index int
Get verb from the verified sentence.

Returns:

Object | Boolean
hasInput() → {Boolean}

Defined in: adventure/Input.js, line 814

Does the input object have verified input?

Returns:

Boolean
hasPhrase(index) → {Boolean}

Defined in: adventure/Input.js, line 437

Parameters:

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

Returns:

Boolean
hasVerb(index) → {Object|Boolean}

Defined in: adventure/Input.js, line 285

Parameters:

  • index int
Get verb from the verified sentence.

Returns:

Object | Boolean
overrideOutput(msg) → {boolean}

Defined in: adventure/Input.js, line 259

Parameters:

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

Returns:

boolean
prependToOutput(msg) → {boolean}

Defined in: adventure/Input.js, line 272

Parameters:

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

Returns:

boolean
pushParsedWord(params)

Defined in: adventure/Input.js, line 899

Parameters:

  • params Object
Push a parsed word to parsed_sentence.
resetStructure()

Defined in: adventure/Input.js, line 386

Reset the verified sentence structure (after revising verified_sentence).
setAsset(index, parsedNoun)

Defined in: adventure/Input.js, line 524

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.
setAssumed(index) → {Object|Boolean}

Defined in: adventure/Input.js, line 712

Parameters:

  • index int
Set verified noun assumed.

Returns:

Object | Boolean
setDirection(index, value)

Defined in: adventure/Input.js, line 648

Parameters:

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

Defined in: adventure/Input.js, line 853

Parameters:

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

Defined in: adventure/Input.js, line 487

Parameters:

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

Returns:

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

Defined in: adventure/Input.js, line 799

Parameters:

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

Returns:

*
setNewPhrase(params) → {Int}

Defined in: adventure/Input.js, line 572

Parameters:

  • params Object
Create a new phrase at the lowest available phrase number. Assumed is always true.

Returns:

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

Defined in: adventure/Input.js, line 460

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(params)

Defined in: adventure/Input.js, line 838

Parameters:

  • params Object
Indicate that this turn parsed one word, which may satisfy a disambiguation prompt.
setParsedNoun(index, parsedNoun)

Defined in: adventure/Input.js, line 671

Parameters:

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

Defined in: adventure/Input.js, line 683

Parameters:

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

Defined in: adventure/Input.js, line 350

Parameters:

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

Defined in: adventure/Input.js, line 626

Parameters:

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

Defined in: adventure/Input.js, line 825

Parameters:

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

Defined in: adventure/Input.js, line 877

Todos: replace with verified sentence structure

Set the parsed sentence structure.
setVerb(value)

Defined in: adventure/Input.js, line 334

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".
setVessel(index, asset)

Defined in: adventure/Input.js, line 543

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.
setVessel(index, asset)

Defined in: adventure/Input.js, line 559

Parameters:

  • index Int
  • asset Object
When player refers to a substance, some verbs will try to identify a vessel containing that substance. Get that vessel id. Returns null if not found.
swapNouns(index1, index2) → {Object|Boolean}

Defined in: adventure/Input.js, line 741

Parameters:

  • index1 int
  • index2 int
Swap two nouns

Returns:

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

Defined in: adventure/Input.js, line 724

Parameters:

  • index1 int
  • index2 int
Swap two phrases

Returns:

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

Defined in: adventure/Input.js, line 766

Parameters:

  • index1 int
  • index2 int
Swap two prepositions

Returns:

Object | Boolean

Properties  | 

allow_circular_verb :Boolean

Defined in: adventure/Input.js, line 176

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.
disambiguate :int

Defined in: adventure/Input.js, line 152

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 :String

Defined in: adventure/Input.js, line 109

Default value: ""

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

Defined in: adventure/Input.js, line 237

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

Defined in: adventure/Input.js, line 29

Default value: ""

Save the original input string for later reference.
input_verb :String

Defined in: adventure/Input.js, line 117

Default value: ""

A string representing the verb that was found in player input.
joint :Array

Defined in: adventure/Input.js, line 210

Default value: []

During parse we perform regex to join verb phrases. For example, if player inputs "write name on paper with pencil", joinVerbNounPrepNounPrepNouns() would find and join "write_on_with paper pencil". When we do a replacement, we're saving the original string and the original verb. Here we save the fomr of the verb phrase, ie verb_noun_prep_noun_prep_noun, for use in verb logic.
output_class :String

Defined in: adventure/Input.js, line 101

Default value: ""

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

Defined in: adventure/Input.js, line 94

The parsed version of the player's input string.
parsed_sentence :Array

Defined in: adventure/Input.js, line 52

Default value: []

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

Defined in: adventure/Input.js, line 44

Default value: { 'enabled':false }

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

Defined in: adventure/Input.js, line 944

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

Defined in: adventure/Input.js, line 977

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

Defined in: adventure/Input.js, line 955

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

Defined in: adventure/Input.js, line 989

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

Defined in: adventure/Input.js, line 966

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

Defined in: adventure/Input.js, line 1001

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

Defined in: adventure/Input.js, line 911

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

Defined in: adventure/Input.js, line 922

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

Defined in: adventure/Input.js, line 933

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

Defined in: adventure/Input.js, line 71

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

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

Defined in: adventure/Input.js, line 194

Default value: {}

During parsing we replace substrings with other substrings. Here we keep a record of the source substrings.
soft_prompt :Boolean

Defined in: adventure/Input.js, line 131

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 :Array

Defined in: adventure/Input.js, line 202

Default value: []

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

Defined in: adventure/Input.js, line 124

Default value: undefined

If parser found an unknown word, store it here.
unparsed_input :String

Defined in: adventure/Input.js, line 87

Default value: ""

The original unparsed player's input string.
verb_chain :Array

Defined in: adventure/Input.js, line 167

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

Defined in: adventure/Input.js, line 185

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".
verified_sentence :Object

Defined in: adventure/Input.js, line 36

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 :Array

Defined in: adventure/Input.js, line 60

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.