parser
index
/home/achifaifa/git/kirino/source/parser.py

Parser functions.
 
Processes a given string and performs the action the string is asking for
 
The parser, error and other data is located in ../data/parser/
The data is loaded by default in this module, so it is also loaded automagically when importing it.
To modify the data files, please read the instructions in these files.

 
Modules
       
common
config
help
npc
os
random
sys

 
Functions
       
chat(dude, player)
Starts a ""conversation"" with an NPC or other ""intelligent"" creature.
 
Needs an object, with information that can be used (NPC/mob) and a player object
equip()
fight()
load()
Data file loading function.
 
Load the data in ../data/parser/words,errors to data structures
look(dungeon, player)
Generates a description about what the player can see from its position. 
 
It uses the filled array from the dungeon object to look for things.
Talks about enemies, objects, money and space in a very general sense and without many details. 
The output, verbosity and content will be improved in future versions.
parse(words, player, dungeon, config)
Main parsing function. 
 
Splits the string and identifies action, target and options
 
Needs a string to be parsed and player, dungeon and config objects.
 
Returns an action code and a message if needed.
 
0) No action
  Look sentences only return a description of the place
  Empty, weird or non-interpretable sentences return an error string
 
1) Move
  11 north
  12 south
  13 east
  14 west
  15 northeast
  16 northwest
  17 southeast
  18 southwest
 
  19 down (next floor)
 
3) "use" actions
  31 use stairs (next floor)
 
4) Combat actions
  Pending
 
5) Configuration
 
6) Help
  61 Help keys (Show key mapping)
  62 General help (Brings the help menu up)
 
It evaluates the verb in the first position and the options next
e.g.: go north, hit zombie, run southeast, walk nw, equip itemname, etc.
If the first word of the string is not a verb (i.e. I want to walk north) a random generic error message will be returned.
parseconv(convstr, dude, player)
Parses a conversation string. 
 
Needs the string, a player object and the thing the player is chatting with
use(words)

 
Data
        dictionary = {}
errors = []
insistor = {}