Class:Parser
Defined in: adventure/Parser.js, line 5
Description
The Parser class interprets player input. In short, it takes a string, sanitizes it of undesirable characters, performs several operations to strip away extraneous grammar such as definite/indefinite articles, performs a number of regular expression searches, compares the input against different verb/noun patterns stored in a lookup table, all to reduce input to a simple format such as 'verb noun noun'. Parser can accept one verb and up to three nouns. Clauses joined by 'and' or 'then' are split into multiple inputs and queued for serial handling.
This is an internal class that authors should not need to construct, though there are methods to allow authors to inject their own custom parser code. See Custom Parsers for more info.
Here are some examples of inputs and how they would be parsed.
Examples:
- unlock the icy door with the glass key
parses to => unlock icy_door glass_key
- ask Mr. Giles about Mrs. Beasley
parses to => ask_about mr_giles mrs_beasley
- climb over to branch
parses to => climb_to branch
- swing from the tree to the cliff on the vine
parses to => swing_from_to_on tree cliff vine
- look at the zebra through the binoculars
parses to => lookAt_through zebra binoculars
- unlock door then open door then go north
parses to three inputs => unlock door / open door / go north
Private Constructor:
var foo = new adventurejs.Parser(game)
Parameters:
-
game
Game
A reference to the game instance.
- Index
- Methods
- Properties
Index
Methods:
- categorizeParsedNoun
- createCustomParser
- disableCustomParser
- enableCustomParser
- excludeFromParsedNoun
- findCharacterComma
- findMatchIn
- getInputCount
- getLastInput
- getNewerInput
- getOlderInput
- handleSentence
- handleWord
- isParsingMultiple
- joinCompoundNames
- joinCompoundPhrases
- joinCompoundPrepositions
- joinPhrasalVerbNounPrepNounPrepNouns
- joinPhrasalVerbNounPrepNouns
- joinPhrasalVerbNounPrepPrepNouns
- joinPhrasalVerbNounPreps
- joinPhrasalVerbPrepNounPrepNounPrepNouns
- joinPhrasalVerbPrepNounPrepNouns
- joinPhrasalVerbPrepNouns
- joinPhrasalVerbPrepPrepNouns
- joinPhrasalVerbPrepPrepPrepNouns
- joinPhrasalVerbs
- parseInput
- parseNoInput
- parseNoun
- parseNumbers
- parseSentence
- parseStrings
- parseVerb
- printNounDisambiguation
- qualifyParsedNoun
- qualifyParsedVerb
- sanitizeInput
- saveVerbPhrase
- selectAll
- selectCarried
- selectCharacter
- selectDOV
- selectExtant
- selectGlobalSubstance
- selectHeld
- selectInHands
- selectInHandsUnlessReservoir
- selectInInventory
- selectInInventoryIfTakeable
- selectIntangible
- selectIOV
- selectKnown
- selectMatter
- selectNotExit
- selectNotGlobal
- selectNotInHands
- selectNotInInventory
- selectNotNestedInventoryIfAll
- selectNotParent
- selectNotParentOrRoom
- selectNotPlayer
- selectNotScenery
- selectNotSelf
- selectNotSubstance
- selectNotWorn
- selectNotWornIfAll
- selectParent
- selectParentOrRoom
- selectPlayer
- selectPresent
- selectPresentIfTangible
- selectReachable
- selectReachableIfTangible
- selectReservoir
- selectReservoirIfSubstance
- selectReservoirOrCarriedIfSubstance
- selectSelf
- selectSingular
- selectSubstance
- selectTakeable
- selectTangible
- selectTangibleOrSubstance
- selectVisible
- selectVisible
- selectVisibleIfTangible
- set
- splitByPeriods
- splitByThens
- stripArticles
- stripConjunctions
- verifyAdverbs
- verifyCharacterCanDoVerb
- verifySentence
- verifySentenceStructure
Properties:
Methods Collapse all |
categorizeParsedNoun
categorizeParsedNoun() → {object}
Defined in: adventure/Parser.js, line 274
Returns:
object
createCustomParser
createCustomParser(parsers)
Defined in: adventure/parser/createCustomParser.js, line 7
Parameters:
-
parsers
Object
An object containing one or more parser functions.
disableCustomParser
disableCustomParser(parser)
Defined in: adventure/parser/disableCustomParser.js, line 7
Parameters:
-
parser
String
The name of a previously created parser that has been stored at game.parser.custom_parsers[name].
enableCustomParser
enableCustomParser(parser)
Defined in: adventure/parser/enableCustomParser.js, line 7
Parameters:
-
parser
String
The name of a previously created parser that has been stored at game.parser.custom_parsers[name].
excludeFromParsedNoun
excludeFromParsedNoun() → {object}
Defined in: adventure/Parser.js, line 257
Returns:
object
findCharacterComma
findCharacterComma(input) → {String}
Defined in: adventure/parser/findCharacterComma.js, line 8
Todos: this needs to consider names with spaces in them or serialized names
Parameters:
-
input
String
Player input.
Returns:
String
findMatchIn
findMatchIn(newQualified, oldQualified) → {Object}
Defined in: adventure/parser/findMatchIn.js, line 8
Parameters:
-
newQualified
Object -
oldQualified
Object
Returns:
Object
foundMatch
getInputCount
getInputCount() → {int}
getLastInput
getLastInput() → {String}
getNewerInput
getNewerInput()
Defined in: adventure/Parser.js, line 180
getOlderInput
getOlderInput()
Defined in: adventure/Parser.js, line 161
handleSentence
handleSentence()
Defined in: adventure/parser/handleSentence.js, line 8
handleWord
handleWord()
Defined in: adventure/parser/handleWord.js, line 8
isParsingMultiple
isParsingMultiple()
Defined in: adventure/Parser.js, line 202
Todos: Is this and is_input_queued duplicative?
joinCompoundNames
joinCompoundNames(input) → {String}
Defined in: adventure/parser/joinCompoundNames.js, line 8
Parameters:
-
input
String
Player input.
Search input for compound object names, by comparing the input string against entries in this.game.world lookup table, which was populated during the creation of Game objects. If we find multiple words that match an entry, we compress the words into a single string that is a noun id.
For example:
"turn on brass lantern"
becomes
"turn on brass_lantern"
.
Returns:
String
joinCompoundPhrases
joinCompoundPhrases(input) → {String}
Defined in: adventure/parser/joinCompoundPhrases.js, line 8
Todos: This might be too greedy, or perhaps need to exclude first word of input. I had a room called "Put Plug In This" and this method parsed "put plug in sink" to "put_plug_in_this in sink" Alternately, revise the method that populates world_lookup for instance world_lookup has keys for "Plug Something With Something" and "sink with"
Parameters:
-
input
String
Player input.
Search input for multi-word phrases that are not names, such as "north door" to describe an aperture related to a north exit, by comparing the input string against entries in game.world_lookup, which contains space delimited phrases as well as single words which make up those phrases.
For example if we had an object named: "Maxwell's silver hammer"
User might ask for "hammer" or "silver hammer" or "maxwell's silver hammer" In order to maximize chances of understanding partial user input, each word of the phrase becomes a separate entry in world_lookup.
When performing search/replace we don't want to accidentally replace substrings of larger phrases, which means we need to search for longer phrases first and work our way down. We also need to ensure we don't substitute words in phrases we've already serialized.
Unfortunately we can't just sort world_lookup by word count because JS object properties aren't indexed, by definition. Instead we figure out the longest word count property and do a loop for each word count from the longest down to two words. (No substitution is needed for single words.)
Returns:
String
joinCompoundPrepositions
joinCompoundPrepositions(input) → {String}
Defined in: adventure/parser/joinCompoundPrepositions.js, line 8
Parameters:
-
input
String
Player input.
Returns:
String
joinPhrasalVerbNounPrepNounPrepNouns
joinPhrasalVerbNounPrepNounPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbNounPrepNounPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb noun prep noun prep noun". We compare the input string against entries in dictionary.verb_noun_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that matches an entry, we save a record for use with future verb logic.
For example:
"tie dog to tree with rope"
is identified as
"tie_to_with dog tree rope"
Returns:
String
joinPhrasalVerbNounPrepNouns
joinPhrasalVerbNounPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbNounPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb noun preposition noun". We compare the input string against entries in dictionary.verb_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"ask grocer about eggplant"
is identified as
"ask_about grocer eggplant"
Returns:
String
joinPhrasalVerbNounPrepPrepNouns
joinPhrasalVerbNounPrepPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbNounPrepPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb noun preposition preposition noun". We compare the input string against entries in dictionary.verb_noun_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"take skateboard from under bed"
is identified as
"take_from skateboard bed"
Returns:
String
joinPhrasalVerbNounPreps
joinPhrasalVerbNounPreps(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbNounPreps.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb noun preposition". We compare the input string against entries in dictionary.verb_noun_preps, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"look in chest"
is identified as
"lookIn chest"
Returns:
String
joinPhrasalVerbPrepNounPrepNounPrepNouns
joinPhrasalVerbPrepNounPrepNounPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbPrepNounPrepNounPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb preposition noun preposition noun preposition noun". We compare the input string against entries in dictionary.verb_prep_noun_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"swing from tree to stalactite on vine"
is identified as
"swing_from_to_on tree stalactite vine"
.
Returns:
String
joinPhrasalVerbPrepNounPrepNouns
joinPhrasalVerbPrepNounPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbPrepNounPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb prep noun prep noun". We compare the input string against entries in dictionary.verb_prep_noun_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"jump from branch to vine"
is identified as
"jumpFrom_to branch vine"
Returns:
String
joinPhrasalVerbPrepNouns
joinPhrasalVerbPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb prep noun". We compare the input string against entries in dictionary.verb_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"look in desk"
is identified as
"lookIn desk"
Returns:
String
joinPhrasalVerbPrepPrepNouns
joinPhrasalVerbPrepPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbPrepPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb prep prep noun". We compare the input string against entries in dictionary.verb_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"get out of boat"
is identified as
"go_out boat"
Returns:
String
joinPhrasalVerbPrepPrepPrepNouns
joinPhrasalVerbPrepPrepPrepNouns(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbPrepPrepPrepNouns.js, line 8
Parameters:
-
input
String
Player input.
Search input for verb phrases in the format of "verb prep prep prep noun". We compare the input string against entries in dictionary.verb_prep_prep_prep_nouns, which was populated by Verb definitions. If we find a set of words that match an entry, we save a record for use with future verb logic.
For example:
"get out from behind boulder"
is identified as
"go_out_from_behind boulder"
Returns:
String
joinPhrasalVerbs
joinPhrasalVerbs(input) → {String}
Defined in: adventure/parser/joinPhrasalVerbs.js, line 26
Parameters:
-
input
String
Player input.
joinPhrasalVerbs
identifies phrasal or compound verb
patterns such as "swing from tree to cliff on vine". This feature
is mostly retired but for use in a small few instances such as
aiding in identifying "plug in computer" vs "plug drain". An earlier
version of the parser used this extensively to join phrasal verbs
into distinct verbs such as "swing_from_to_on tree cliff vine",
which worked well but ultimately proved to be inflexible.
The listed order of regex operations is important. We're calling them in order of longest to shortest, to ensure we don't accidentally catch partial phrases, like only finding "swing_from" out of "swing from tree to cliff on vine", and then not finding "swing_from_to_on", which is a distinct pattern.
Returns:
String
parseInput
parseInput(input)
Defined in: adventure/parser/parseInput.js, line 8
Parameters:
-
input
String
Player input.
parseNoInput
parseNoInput()
Defined in: adventure/Parser.js, line 213
parseNoun
parseNoun(word) → {adventurejs.parsedNoun}
Defined in: adventure/parser/parseNoun.js, line 8
Parameters:
-
word
String
Returns:
adventurejs.parsedNoun
parseNumbers
parseNumbers(input) → {String}
Defined in: adventure/parser/parseNumbers.js, line 8
Parameters:
-
input
String
Player input.
Example:
type 10 on keyboard
Becomes:
type global_number on keyboard
Returns:
String
parseSentence
parseSentence()
Defined in: adventure/parser/parseSentence.js, line 8
parseStrings
parseStrings(input) → {String}
Defined in: adventure/parser/parseStrings.js, line 8
Parameters:
-
input
String
Player input.
Example:
type "foo" on keyboard
Becomes:
type global_string on keyboard
Returns:
String
parseVerb
parseVerb(verb) → {String}
Defined in: adventure/parser/parseVerb.js, line 8
Parameters:
-
verb
String
One word from input string.
Returns:
String
printNounDisambiguation
printNounDisambiguation(params)
Defined in: adventure/parser/printNounDisambiguation.js, line 8
Parameters:
-
params
Object
qualifyParsedNoun
qualifyParsedNoun(params) → {adventurejs.parsedNoun}
Defined in: adventure/parser/qualifyParsedNoun.js, line 8
Parameters:
-
params
Object
Returns:
adventurejs.parsedNoun
qualifyParsedVerb
qualifyParsedVerb(params) → {adventurejs.parsedVerb}
Defined in: adventure/parser/qualifyParsedVerb.js, line 8
Parameters:
-
params
Object
Returns:
adventurejs.parsedVerb
sanitizeInput
sanitizeInput(parsed_input, unparsed_input) → {Array}
Defined in: adventure/parser/sanitizeInput.js, line 8
Parameters:
-
parsed_input
String -
unparsed_input
String
- toLowerCase(), excluding quoted text
- strip trailing "."
- replace tabs with spaces
- trim()
- reduce multiple spaces to single
- replace " and then " with " then "
- split by periods
- split by "then"
- check for "again"
Returns:
Array
[string, string]
saveVerbPhrase
saveVerbPhrase()
Defined in: adventure/parser/saveVerbPhrase.js, line 8
selectAll
selectAll(word) → {Array}
Defined in: adventure/parser/selectAll.js, line 8
Parameters:
-
word
String
Returns:
Array
selectCarried
selectCarried(list) → {Array}
Defined in: adventure/parser/selectCarried.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectCharacter
selectCharacter(list) → {Array}
Defined in: adventure/parser/selectCharacter.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectDOV
selectDOV(list) → {Array}
Defined in: adventure/parser/selectDOV.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectExtant
selectExtant(list) → {Array}
Defined in: adventure/parser/selectExtant.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectGlobalSubstance
selectGlobalSubstance(list) → {Array}
Defined in: adventure/parser/selectGlobalSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectHeld
selectHeld(list) → {Array}
Defined in: adventure/parser/selectHeld.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectInHands
selectInHands(list) → {Array}
Defined in: adventure/parser/selectInHands.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectInHandsUnlessReservoir
selectInHandsUnlessReservoir(list) → {Array}
Defined in: adventure/parser/selectInHandsUnlessReservoir.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectInInventory
selectInInventory(list) → {Array}
Defined in: adventure/parser/selectInInventory.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectInInventoryIfTakeable
selectInInventoryIfTakeable(list) → {Array}
Defined in: adventure/parser/selectInInventoryIfTakeable.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectIntangible
selectIntangible(list) → {Array}
Defined in: adventure/parser/selectIntangible.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectIOV
selectIOV(list) → {Array}
Defined in: adventure/parser/selectIOV.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectKnown
selectKnown(list) → {Array}
Defined in: adventure/parser/selectKnown.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectMatter
selectMatter(list) → {Array}
Defined in: adventure/parser/selectMatter.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotExit
selectNotExit(list) → {Array}
Defined in: adventure/parser/selectNotExit.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotGlobal
selectNotGlobal(list) → {Array}
Defined in: adventure/parser/selectNotGlobal.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotInHands
selectNotInHands(list) → {Array}
Defined in: adventure/parser/selectNotInHands.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotInInventory
selectNotInInventory(list) → {Array}
Defined in: adventure/parser/selectNotInInventory.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotNestedInventoryIfAll
selectNotNestedInventoryIfAll(list) → {Array}
Defined in: adventure/parser/selectNotNestedInventoryIfAll.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotParent
selectNotParent(list) → {Array}
Defined in: adventure/parser/selectNotParent.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotParentOrRoom
selectNotParentOrRoom(list) → {Array}
Defined in: adventure/parser/selectNotParentOrRoom.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotPlayer
selectNotPlayer(list) → {Array}
Defined in: adventure/parser/selectNotPlayer.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotScenery
selectNotScenery(list) → {Array}
Defined in: adventure/parser/selectNotScenery.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotSelf
selectNotSelf(list) → {Array}
Defined in: adventure/parser/selectNotSelf.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotSubstance
selectNotSubstance(list) → {Array}
Defined in: adventure/parser/selectNotSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotWorn
selectNotWorn(list) → {Array}
Defined in: adventure/parser/selectNotWorn.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectNotWornIfAll
selectNotWornIfAll(list) → {Array}
Defined in: adventure/parser/selectNotWornIfAll.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectParent
selectParent(list) → {Array}
Defined in: adventure/parser/selectParent.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectParentOrRoom
selectParentOrRoom(list) → {Array}
Defined in: adventure/parser/selectParentOrRoom.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectPlayer
selectPlayer(list) → {Array}
Defined in: adventure/parser/selectPlayer.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectPresent
selectPresent(list) → {Array}
Defined in: adventure/parser/selectPresent.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectPresentIfTangible
selectPresentIfTangible(list) → {Array}
Defined in: adventure/parser/selectPresentIfTangible.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectReachable
selectReachable(list) → {Array}
Defined in: adventure/parser/selectReachable.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectReachableIfTangible
selectReachableIfTangible(list) → {Array}
Defined in: adventure/parser/selectReachableIfTangible.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectReservoir
selectReservoir(list) → {Array}
Defined in: adventure/parser/selectReservoir.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectReservoirIfSubstance
selectReservoirIfSubstance(list) → {Array}
Defined in: adventure/parser/selectReservoirIfSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectReservoirOrCarriedIfSubstance
selectReservoirOrCarriedIfSubstance(list) → {Array}
Defined in: adventure/parser/selectReservoirOrCarriedIfSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectSelf
selectSelf(list) → {Array}
Defined in: adventure/parser/selectSelf.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectSingular
selectSingular(list) → {Array}
Defined in: adventure/parser/selectSingular.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectSubstance
selectSubstance(list) → {Array}
Defined in: adventure/parser/selectSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectTakeable
selectTakeable(list) → {Array}
Defined in: adventure/parser/selectTakeable.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectTangible
selectTangible(list) → {Array}
Defined in: adventure/parser/selectTangible.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectTangibleOrSubstance
selectTangibleOrSubstance(list) → {Array}
Defined in: adventure/parser/selectTangibleOrSubstance.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectVisible
selectVisible(list) → {Array}
Defined in: adventure/parser/selectVisible.js, line 8
Todos: consider global darkness
Parameters:
-
list
Array
Returns:
Array
selectVisible
selectVisible(list) → {Array}
Defined in: adventure/parser/selectWorn.js, line 8
Parameters:
-
list
Array
Returns:
Array
selectVisibleIfTangible
selectVisibleIfTangible(list) → {Array}
Defined in: adventure/parser/selectVisibleIfTangible.js, line 8
Todos: consider global darkness
Parameters:
-
list
Array
Returns:
Array
set
set(props) → {adventurejs.Parser}
Defined in: adventure/Parser.js, line 342
Parameters:
-
props
Object
A generic object containing properties to copy to the Object instance.
Returns:
adventurejs.Parser
Returns the instance the method is called on (useful for chaining calls.)
splitByPeriods
splitByPeriods(input) → {Array}
Defined in: adventure/parser/splitByPeriods.js, line 8
Parameters:
-
input
String
Returns:
Array
splitByThens
splitByThens(input) → {String}
Defined in: adventure/parser/splitByThens.js, line 8
Parameters:
-
input
String
Example: "take sword then go north"
Returns:
String
stripArticles
stripArticles(input) → {String}
Defined in: adventure/parser/stripArticles.js, line 8
Parameters:
-
input
String
Player input.
Convert some common compound prepositions into single words to streamline preposition handling.
Returns:
String
stripConjunctions
stripConjunctions(input) → {String}
Defined in: adventure/parser/stripConjunctions.js, line 8
Parameters:
-
input
String
Player input.
In order to handle sentences with multiple clauses connected by conjunctions 'and' or 'but', we convert them to symbols we can use down the line.
Returns:
String
verifyAdverbs
verifyAdverbs()
Defined in: adventure/parser/verifyAdverb.js, line 8
verifyCharacterCanDoVerb
verifyCharacterCanDoVerb(optional_verb)
Defined in: adventure/parser/verifyCharacterCanDoVerb.js, line 8
Parameters:
-
optional_verb
string
An optional verb. If not provided, method uses this_turn.input_verb.
Returns:
booleanverifySentence
verifySentence()
Defined in: adventure/parser/verifySentence.js, line 8
verifySentenceStructure
verifySentenceStructure()
Defined in: adventure/parser/verifySentenceStructure.js, line 8
Properties |
custom_parsers
custom_parsers :Object
Defined in: adventure/Parser.js, line 75
Default value: {}
custom_parsers_enabled
custom_parsers_enabled :Object
Defined in: adventure/Parser.js, line 82
Default value: {}
dictionary
dictionary :Object
Defined in: adventure/Parser.js, line 61
Default value: {}
display
display :Object
Defined in: adventure/Parser.js, line 68
Default value: {}
game
game :Object
Defined in: adventure/Parser.js, line 54
Default value: {}
input_history
input_history :Array
Defined in: adventure/Parser.js, line 105
Default value: []
input_history_index
input_history_index :int
Defined in: adventure/Parser.js, line 122
input_object
input_object :Object
input_queue
input_queue :Array
Defined in: adventure/Parser.js, line 129
Default value: []
input_string
input_string :String
Defined in: adventure/Parser.js, line 91
Default value: ""
is_input_queued
is_input_queued :Boolean
Defined in: adventure/Parser.js, line 146
Default value: false
phrasal_patterns
phrasal_patterns :Array
Defined in: adventure/parser/joinPhrasalVerbs.js, line 8