Class Index | File Index

Classes


Class com.jiffeegames.Verbs

A Verbs object defines and implements the creation of new verbs with which the user can manipulate the game.
Defined in: jiffee-verbs.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a Verbs object.
Method Summary
Method Attributes Method Name and Description
 
checkModifiers_(event, modifiers)
Run through a modifier list.
 
describe(verb, direct)
Define the action which should be performed when a certain verb is used in a certain context.
<static>  
com.jiffeegames.Verbs.es()
Set the language to Spanish.
 
init(locate, language)
 
Helper function to parse one modifier clause.
Class Detail
com.jiffeegames.Verbs()
Create a Verbs object. The typical call is:
var verbs = new com.jiffeegames.Verbs();
Method Detail
{void} checkModifiers_(event, modifiers)
Run through a modifier list. If everything matches, return. If anything fails to match, throw 'rule done' to force this rule to terminate. Return a list of any applicable override actions.
Parameters:
event
modifiers

{Rule} describe(verb, direct)
Define the action which should be performed when a certain verb is used in a certain context. This is a convenience routine, which simply creates and adds an appropriate rule to make the action occur at the desired time. It does not express the full generality possible with JIFFEE rules, but it does provide enough power to get started writing interesting games before learning to write JavaScript functions. The full form is:
verbs.describe(<verb>,
               <noun>|"*"|"",
               <optional modifier clause>, ...
               <action>
              );
where each <modifier clause> is one of:
               <selection clause>, ...
               <override clause>, ...
and each <selection clause> is one of:
               "<preposition> <noun>",
               "WHEN <noun> IS [NOT] CARRIED",
               "WHEN <noun> IS [NOT] HERE",
               "WHEN <noun> IS [NOT] REACHABLE",
               "WHEN <noun> IS [NOT] AT <place>",
and each <override clause> is one of:
               "DIRECT OBJECT OVERRIDES",
               "PLACE OVERRIDES",
and each <noun> can be any one of:
               the name of a noun,
               "player",
               "DIRECT OBJECT".
and a typical call would be:
verbs.describe("give", "box",
               "to dwarf",
               "WHEN box IS CARRIED",
               "WHEN PLAYER IS AT bridge",
               ["The troll winks and mutters a strange incantation.",
                "MOVE PLAYER TO forest"]
              );
If any of the selection clauses does not match, this verb description does nothing and JIFFEE will keep looking for another rule or description that does match. In particular, if the player is for example not carrying a noun that a selection clause must be carried, no error message will be displayed. If you want that, you have to specify that explicitly with a separate call to verbs.describe(). Note, however, that there are default actions programmed when the command includes the object of a verb or preposition which is not present or carried.
Parameters:
verb
direct
Returns:
The rule that will match for this action.

<static> {void} com.jiffeegames.Verbs.es()
Set the language to Spanish.

init(locate, language)
Parameters:
locate
language

{Array} parseModifier_(clause)
Helper function to parse one modifier clause.
var res = this.parseModifier_(clause);
Parameters:
{String} clause
- the modifier clause in string form
Returns:
a list of [type-of-modifier, optional-arg1, optional-arg2]

Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jul 25 2010 13:49:31 GMT-0700 (PDT)