Marauroa Core API: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
No edit summary
imported>StephenIerodiaconou
No edit summary
Line 82: Line 82:
* ''void isA(RPClass parent)''
* ''void isA(RPClass parent)''


These methods add attributes to the RPClass and set their type and visibility. You can also set the parent of this class. Of course a class can have no parent.
These methods add attributes to the RPClass and set their type and visibility. You can also set the parent of this class. Of course, however, a class can have no parent (be parentless).


Once the class has been filled, you can query the data using these methods. These methods alow you to get the class name of the class, the the type of an attribute, determine if an attribute exists and to know if that RPClass is a subclass of another.<br>
Once the class has been filled, you can query the data using these methods. These methods alow you to get the class name of the class, the the type of an attribute, determine if an attribute exists and to know if that RPClass is a subclass of another.<br>
Line 117: Line 117:
</pre>
</pre>


Each time you create a new RPClass and as long as you give it a name ( ie: player, position, ... ) it will be added to the system list of classes.<br>
Each time you create a new RPClass, as long as you give it a name ( ie: player, position, ... ), it will be added to the system list of classes.<br>
Notice on the example the HIDDEN attribute, by default an attribute is visible.<br>
Notice in the example that the HIDDEN attribute must be specified if you want the RPClass to have this property otherwise by default an attribute is visible.<br>
You can choose not to use RPClasses on your application but the performance penalty will be big both on bandwidth and CPU usage.
Note: You can choose not to use RPClasses in your application BUT the performance penalty will be big on bandwidth and CPU usage.


= RPAction =
= RPAction =
It is a object to represent actions that player wants to do.
RPAction is an object used to represent actions that a player wants to do.
It is up to your game about how to define the content ( you should also define a RPClass for these ).
It is up to you to create these when you design your game as they are specific to each game ( you should also define a RPClass for these ).


= RPObject and RPSlot =
= RPObject and RPSlot =
An RPObject is the containter of data in Arianne. An RPObject ''isa'' Attributes with a list of RPSlots. Think about RPSlots as backpacks, pockets, boxes, ...<br>
RPObjects are the containters of data in Arianne. An RPObject is an (''isa'' function) Attributes element with a list of RPSlots attached. <br>
RPSlots are slots on objects that items can be placed on/in, such as backpacks, pockets, boxes, ...<br>
The new methods are:
The methods of the RPObject to modify slots are:
* void addSlot(RPSlot slot)
* ''void addSlot(RPSlot slot)''
* RPSlot getSlot(String name)
* void removeSlot(String name)
* ''RPSlot getSlot(String name)''
* boolean hasSlot(String name)
* ''void removeSlot(String name)''
* ''boolean hasSlot(String name)''
* Iterator slotIterator()
* ''Iterator slotIterator()''
The above methods are used to add a slot to the object, retrieve it, remove it and test if the slot exists. Finally the slot iterator is used to visit all the slots in the object.


* ''RPObject.ID getID()''
These methods adds a slot to the object, retrieve it, remove it and test if the slot exists. Finally the slot iterator is used to visit all the slots in the object.
This is a helper method to get the unique ID of the object.


RPSlot class elements also have a simple API:
* RPObject.ID getID()
This is a helper method to get the ID of the object.

RPSlot has also a very simple API:
* void add(RPObject object)
* void add(RPObject object)
* RPObject get(RPObject.ID id)
* RPObject get(RPObject.ID id)
Line 145: Line 145:
* RPObject remove(RPObject.ID id)
* RPObject remove(RPObject.ID id)
* void clear()
* void clear()
These methods modify objects in the RPSlot.

The clear removes all the object of the slot.
The clear() method removes all the objects in the slot.


* Iterator iterator()
* Iterator iterator()
Line 164: Line 164:
</pre>
</pre>


Now the complex part, where all the nuts are: IRPZone and IRPRuleProcessor interfaces
Now for the complex part. Where it all becomes a little nuts!: IRPZone and IRPRuleProcessor interfaces


=RPWorld=
=RPWorld=
TODO
TODO

=IRPZone=
=IRPZone=
This is the class that handle the world content and the perceptions. It would be wise to forget about it, or extend MarauroaRPZone instead as it is a really complex and bug prone class.<br>
IRPZone is the class that handles the world content and the perceptions. It would be wise to forget about it, or extend MarauroaRPZone instead as it's a complex and error prone class. <br>
The methods are:
The methods are:
<pre>
<pre>
/** This method is called when the zone is created to popullate it */
/** This method is called when the zone is created to populate it */
public void onInit() throws Exception;
public void onInit() throws Exception;
/** This method is called when the server finish to save the content of the zone */
/** This method is called when the server finish to save the content of the zone */
Line 204: Line 205:
</pre>
</pre>


In most of the cases all you will like to modify are:
In most of the cases all you will wish to modify are:
* onInit
* onInit
* onFinish
* onFinish
Line 211: Line 212:


=IRPRuleProcessor=
=IRPRuleProcessor=
This class *MUST* be implemented fully, but it is a child toy compared to IRPZone :). Here is where you code all your games rules.<br>
This class *MUST* be implemented fully, but it is a childs toy compared to IRPZone :). This is where you code all your games rules.<br>
The API is as:
The API is as follows:
<pre>
<pre>
/** Set the context where the actions are executed.
/** Set the context where the actions are executed.