Marauroa Core API: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
imported>Blacklads
Undo revision 11663 by Ufizavipupu (Talk)
 
(48 intermediate revisions by 3 users not shown)
Line 3:
 
 
Marauroa exposes a very simplified and reduced API so you can easily develop your own games. A nightly build [http://stendhal.game-hoststendhalgame.org/hudson/job/marauroa_HEAD/javadoc/ JavaDoc API Documentation] is available, too.
 
== Content ==
[[Image:Classdiagram_marauroa.common.game_rp_stubs.png|thumb|Class Diagram of RP* classes]]
 
The main entities you should know about are:
* Attributes
Line 209 ⟶ 211:
Now for the complex part. Where it all becomes a little nuts!: IRPZone and IRPRuleProcessor interfaces
 
==RPWorld==
This class is just a container of zones.
 
Line 216 ⟶ 218:
onInit and onFinish are called on server startup and finalization. You need to subclass RPWorld to give proper behaviour to them.
 
<source lang="java">
public void onInit() throws Exception
public void onFinishonInit() throws Exception
public void onInitonFinish() throws Exception
</source>
 
Some helper methods to add zones and iterate them.
 
<source lang="java">
public void addRPZone(IRPZone zone)
public IRPZonevoid getRPZoneaddRPZone(IRPZone.ID zoneidzone)
public IRPZone getRPZone(RPObjectIRPZone.ID objectidzoneid)
public Iterator<IRPZone> iteratorgetRPZone(RPObject.ID objectid)
public intIterator<IRPZone> sizeiterator()
public int size()
</source>
 
Methods to add, get, test existence, remove and modify objects. modify() is as you know for delta^2 algorithm.
Modify is as you know for delta^2 algorithm.
 
<source lang="java">
public void add(RPObject object) throws NoRPZoneException, RPObjectInvalidException
public RPObjectvoid getadd(RPObject.ID idobject) throws NoRPZoneException, RPObjectInvalidException
public booleanRPObject hasget(RPObject.ID id) throws NoRPZoneException, RPObjectInvalidException
public RPObjectboolean removehas(RPObject.ID id) throws NoRPZoneException, RPObjectNotFoundExceptionRPObjectInvalidException
public voidRPObject modifyremove(RPObject.ID objectid) throws NoRPZoneException, RPObjectNotFoundException
public void addmodify(RPObject object) throws NoRPZoneException, RPObjectInvalidException
</source>
 
These are helper methods for changing the zone of an object. Use them instead of doing it by hand.
 
<source lang="java">
public void changeZone(IRPZone.ID oldzoneid, IRPZone.ID newzoneid, RPObject object) throws NoRPZoneException
public void changeZone(StringIRPZone.ID oldzoneoldzoneid, StringIRPZone.ID newzonenewzoneid, RPObject object) throws NoRPZoneException
public void changeZone(IRPZone.IDString oldzoneidoldzone, IRPZone.IDString newzoneidnewzone, RPObject object) throws NoRPZoneException
</source>
 
==IRPZone==
IRPZone is the interface that handles the world content and the perceptions. In most cases you should use the implementation MarauroaRPZone and extend it.
 
Line 291 ⟶ 300:
* buildMapObjectsList
 
==IRPRuleProcessor==
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 follows:
Line 329 ⟶ 338:
 
[[Category:Marauroa]]
{{#breadcrumbs: [[Marauroa]] | [[Navigation for Marauroa Users|Using]] | [[Marauroa Core API|Core API]]}}