Marauroa Core API: Difference between revisions

Content deleted Content added
imported>StephenIerodiaconou
No edit summary
No edit summary
Line 1:
Marauroa exposes a very simplified and reduced API so you can easily develop your own games.
 
== Content ==
The main entities you should know about are:
* Attributes
Line 18:
 
 
=== Attributes ===
Attributes are pairs of data stored in a list. Each attribute comprises of a ''name'' and ''value'' element. Attributes are the standard way of storing data in Arianne. An example of an attribute is your age, e.g. name="age" and value=21
 
Line 59:
</pre>
 
=== RPClass ===
This class is a key concept of Arianne. An RPClass is much like a Java Class but for Arianne RPObjects: it defines the type ( string, int, boolean, ... ) and the visibility ( hidden attribute or visible attribute ) of the attributes that make up an object (an object is a collection of attributes, e.g. for a human, age, height etc).
 
Line 117:
</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>
== DONE TO HERE ==
Notice on the example the HIDDEN attribute, by default an attribute is visible.<br>
 
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.
Notice on the example the HIDDEN attribute, by default an attribute is visible.
You can choose not to use RPClasses on your application but the performance penalty will be big both on bandwidth and CPU usage.
 
!!= RPAction =
It is a object to represent actions that player wants to do.
It is up to your game about how to define the content ( you should also define a RPClass for these ).
 
!!= RPObject and RPSlot =
An RPObject is the containter of data in Arianne. An RPObject _isa_''isa'' Attributes with a list of RPSlots. Think about RPSlots as backpacks, pockets, boxes, ...<br>
The new methods are:
* void addSlot(RPSlot slot)
Line 135 ⟶ 133:
* boolean hasSlot(String name)
* Iterator slotIterator()
 
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.
 
Line 146 ⟶ 145:
* RPObject remove(RPObject.ID id)
* void clear()
 
The clear removes all the object of the slot.
 
* Iterator iterator()
 
It is used to visit all the objects of the slot.
 
<pre>
<verbatim>
RPObject object=new RPObject(RPClass.getRPClass("player"));
object.put("name","example");
Line 161 ⟶ 162:
slot.add(coin);
object.addSlot(slot);
</verbatimpre>
 
Now the complex part, where all the nuts are: IRPZone and IRPRuleProcessor interfaces
 
!! =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>
The methods are:
<pre>
<verbatim>
/** This method is called when the zone is created to popullate it */
public void onInit() throws Exception;
Line 199 ⟶ 200:
/** Method to create the map to send to player's client */
public java.util.List buildMapObjectsList(RPObject.ID id);
</verbatimpre>
 
In most of the cases all you will like to modify are:
Line 207 ⟶ 208:
 
 
!!=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>
The API is as:
<pre>
<verbatim>
/** Set the context where the actions are executed.
* @param zone The zone where actions happens. */
Line 236 ⟶ 237:
* @param id the new player id that timeouts. */
public boolean onTimeout(RPObject.ID id) throws RPObjectNotFoundException;
</verbatimpre>
 
!!! Questions
Do you have questions? Edit the page and place here.
Regards,
Miguel