Class Index | File Index

Classes


Class com.jiffeegames.Controller

A Controller object coordinates the other main objects in a game. Its basic function is to accept input from the user, perform all the actions appropriate to that input, and assemble the output.
Defined in: jiffee-controller.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a Controller object.
Method Summary
Method Attributes Method Name and Description
 
Add a function to perform a type of object.
 
Do all the work on the rules, one event at a time in FIFO order.
 
init(locate, language)
 
perform(action, event)
Perform an action.
 
Perform an action, and throw 'event done' if there are any changes in state or any output done.
<private>  
performFunction_(action, event)
Perform a function, by executing it.
<private>  
performList_(action, event)
Perform a list, by performing each element of the list in order.
<private>  
performString_(action, event)
Perform a string, by passing it to show().
 
run(raw)
Take a single line of raw input from the user, execute the command(s) it contains, and return the output string that should be displayed.
<private>  
Start all the modules that need starting, in the correct order.
Class Detail
com.jiffeegames.Controller()
Create a Controller object. The normal call is
var controller = com.jiffeegames.Controller();
Method Detail
{void} addPerformer(func)
Add a function to perform a type of object.
Parameters:
{function} func
A function which tries to "perform" an object. The performer function should return true if the object is the right type and the perform succeeds, or false if another performer should be tried. Since "func" will later be called as a free function, it should normally be a closure so that it will have access to any objects it may need.

{void} drainScheduler_()
Do all the work on the rules, one event at a time in FIFO order. For each event, examine all the rules that match that event, in priority-then-LIFO order, and perform the action associated with each rule. As soon as one of the actions outputs something or changes the state (value of a trait), that event is done and all remaining rules are skipped. This normal processing order can be overridden if an action throws a string, in which case the following occurs: No matter what happens with the rules of one event, when that event is done then processing always continues on normally to the following events.

init(locate, language)
Parameters:
locate
language

{void} perform(action, event)
Perform an action.
Parameters:
{String_or_Function} action
The action to be peformed.
{Event} event
The event that matched this action.

{void} performAndCheckForChanges(action, event)
Perform an action, and throw 'event done' if there are any changes in state or any output done.
Parameters:
{String_or_Function} action
The action to be peformed.
{Event} event
The event that matched this action.

<private> {boolean} performFunction_(action, event)
Perform a function, by executing it.
Parameters:
action
event
Returns:
true if the object is the right type and the perform succeeds, false if another performer should be tried.

<private> {boolean} performList_(action, event)
Perform a list, by performing each element of the list in order.
Parameters:
action
event
Returns:
true if the object is the right type and the perform succeeds, false if another performer should be tried.

<private> {boolean} performString_(action, event)
Perform a string, by passing it to show().
Parameters:
action
event
Returns:
true if the object is the right type and the perform succeeds, false if another performer should be tried.

{String} run(raw)
Take a single line of raw input from the user, execute the command(s) it contains, and return the output string that should be displayed.
Parameters:
{String} raw
The raw input from the user.
Returns:
The output which results from running the command.

<private> {void} start()
Start all the modules that need starting, in the correct order.

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