intficpy.parser module¶
-
class
intficpy.parser.
Parser
(game)¶ Bases:
object
-
callVerb
()¶ Gets the Thing objects (if any) referred to in the player command, then calls the verb function
Returns a Boolean, True if a verb function is successfully called, False otherwise
-
checkAdjectives
(noun_adj_arr, noun, things, scope, far_obj, obj_direction)¶ If there are multiple Thing objects matching the noun, check the adjectives to narrow down to exactly 1 Takes arguments self.game.app, noun_adj_arr, a list of strings referring to an in game item, taken from the player command,noun (string), things, a list of Thing objects (things.py) that are candidates for the target of the player’s action, and scope, a string specifying the range of the verb Returns a single Thing object or None
-
checkComponentObjects
()¶ Check if any of the identified objects have subcomponents that are better candidates as objects of the current verb.
-
checkExtra
(verb, verb_form, dobj, iobj)¶ Checks for words unaccounted for by verb form
Returns a list, empty or containing one word strings (extra words)
-
checkForConvCommand
()¶
-
checkForImplicitObjects
()¶ Raises AbortTurn in the event of a missing direct or indirect object.
Returns None, or a list of two items, either lists of strings, or None
-
checkRange
(things, scope)¶ Eliminates all grammatical object candidates that are not within the scope of the current verb Takes arguments self.game.me, things, a list of Thing objects (thing.py) that are candidates for the target of a player’s action, and scope, a string representing the range of the verb Returns a list of Thing objects, or an empty list
-
clearCommand
()¶
-
directionRangeCheck
(obj)¶
-
disambig
()¶ When disambiguation mode is active, use the player input to specify the target for the previous turn’s ambiguous command called by self.parseInput Returns a Boolean, True if disambiguation
-
generateVerbScopeErrorMsg
(scope, noun_adj_arr)¶ Prints the appropriate Thing out of scope message Takes arguments, scope, a string, and noun_adj_arr, a list of strings Returns None
-
getConvCommand
()¶
-
getCurVerb
()¶ Identify the verb Called every turn by self.parseInput Returns a two item list. The first is a Verb object and an associated verb form (list of strings), or None. The second is True if potential verb matches were found, False otherwise
-
getDirection
()¶ Check for direction statement as in “west” or “ne” Called every turn by self.parseInput Raises AbortTurn on discovering & executing a travel command
-
getDisambigIndexFromCommand
()¶
-
getGrammarObj
()¶ Analyze input using the chosen verb_form to find any objects
-
getObjWords
(game, before, after)¶ Create a list of all nouns and adjectives (strings) referring to a direct or indirect object Takes arguments - before, the word expected before the grammatical object (string), - after, the word expected after the grammatical object (string or None), Called by self._analyzeSyntax Returns an array of strings or None
-
getObjectTargets
()¶ Get the IFPObject instances for each of the grammar objects, if applicable
Arguments: - obj_words, array of words or IFPObjects for dobj, iobj
-
getThing
(noun_adj_arr, scope, far_obj, obj_direction)¶ Get the Thing object in range associated with a list of adjectives and a noun Takes arguments noun_adj_array, a list of strings referring to an in game item, taken from the player command, and scope, a string specifying the range of the verb Called by self.callVerb Returns a single Thing object (thing.py) or None
-
getUniqueConcepts
(things)¶ Eliminates all items with duplicate known_ix properties.
-
implicitRemoveNestedInventory
()¶
-
invRangeCheck
(thing)¶ Check if the Thing is in the Player contains Takes arguments self.game.me, pointing to the Player, and thing, a Thing Returns True if within range, False otherwise
-
knowsRangeCheck
(thing)¶ Check if the Player knows about a Thing Takes arguments self.game.me, pointing to the Player, and thing, a Thing Returns True if within range, False otherwise
-
locationsDistinct
(things)¶ Check if identically named items can be distinguished by their locations Takes a list of items to check Returns False if all locations are the same, True otherwise
-
matchPrepKeywords
()¶ Check for prepositions in the self.tokenized player command, and remove any candidate verbs whose preposition does not match Returns a list of Verb objects or an empty list
-
nearRangeCheck
(thing)¶ Check if the Thing is near (room or contains) Takes arguments self.game.me, pointing to the Player, and thing, a Thing Returns True if within range, False otherwise
-
parseInput
(input_string)¶ Parse player input, and respond to commands each turn Takes argument input_string, the raw player input Called by mainLoop in terminal version, turnMain (gui.py) in GUI version Returns 0 when complete
-
recordInput
(input_string)¶
-
replace_string_vars
(text)¶ Perform string replacements for text in the format <<main_module.module.attribute … >>
This should be called by the Game instance when text is added to an event
-
resolveGrammarObjLocations
()¶ Perform implicit actions to bring the objects into verb range where possible.
-
roomDescribe
()¶ Wrapper for room describe function (room.py)
-
roomRangeCheck
(thing)¶ Check if the Thing is in the current room Takes arguments self.game.me, pointing to the Player, and thing, a Thing Returns True if within range, False otherwise
-
runTurnCommand
()¶
-
sendTokensToCurrentSequence
()¶ If there is a sequence in progress, pass in current tokens
-
verbByObjects
()¶ Disambiguates verbs based on syntax used Iterates through verb list, comparing syntax in input to the entries in the .syntax attribute of the verb
-
verboseNamesMatch
(things)¶ Check if any of the potential grammatical objects have identical verbose names Takes the list of things associated with the direct or indirect object Returns a list of two items:
Item one is True if duplicates are present, else False Item two is dictionary mapping verbose names to lists of Things from the input with that name
-
wearRangeCheck
(thing)¶ Check if the Thing is being worn Takes arguments self.game.me, pointing to the Player, and thing, a Thing Returns True if within range, False otherwise
-