Marauroa Core API: Difference between revisions
Content deleted Content added
No edit summary |
imported>StephenIerodiaconou No edit summary |
||
Line 1:
Marauroa
The main entities you should know about are:
* Attributes
Line 9:
* RPClass
If you plan to use Java only
* IRPZone interface
* IRPRuleProcessor interface
Or if you would prefer to use Python for developing the game rules read about:
* ~PythonZone
* PythonRP
=== 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
Each attribute also has a type associated with it that is defined in a ''RPClass''. An attributes is an instance of a ''RPClass'' (see next section of this document to read more on RPClass.
There are two special entries in attributes:
* ''type'': defines the name of the RPClass that the object belongs to.
* ''id'': defines a unique identifier
The methods exposed by the Attributes class to the game developer are shown below. These are the functions you should use to modify your attributes.
Setting the value of an attribute:
* ''void put(String name, String value)''
* ''void put(String name, int value)''
Add a quantity to the value element of an attribute that MUST already exist:
* ''void add(String name, int quantity)''
Returns the value of an attribute:
* ''String get(String name)''
* ''int get(String name)''
Removes an attribute entry from the list of attributes:
* ''void remove(String name)''
Returns True if an attribute exists:
* ''boolean has(String name)''
'''Example''': <br>
<pre>
Attributes test=new Attributes();
test.put("name","Test attribute");
Line 53 ⟶ 57:
test.remove("name");
</
This class is a key concept
RPClass is made up of five different parts:
A data type definition:
*
*
* ''Integer'': a 32 bits integer
* ''Short'': a 16 bits integer
* ''Byte'': a 8 bits integer
* ''Flag'': a binary flag.
The Visibility of the data:
* ''Visible'': if the attribute can be seen by clients.
* ''Hidden'': if the attribute is not visible to clients.
Creation methods of the RPClass: (These are part of each RPClass instance, see example below for usage)
*
*
* ''void isA(String 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.
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>
'''Query''':
* ''String getName()''
* ''byte getType(String name)''
* ''byte getVisibility(String name)''
* ''boolean hasAttribute(String name)''
* ''boolean subclassOf(String parentclass)''
You can query the system classes using these methods. Note that it is '''not''' a good idea to modify them once you are running. The class definitions are send to the client on connect hence if you change the class definitions in the middle of a game you will crash your clients!<br>
'''Class wide query''':
* ''boolean hasRPClass(String name)''
* ''RPClass getRPClass(String name)''
When writting a class definition you can skip the ''id'' and ''type'' attributes as they are automatically determined by RPClass.
'''Example''':<br>
<pre>
RPClass objclass=new RPClass("position");
objclass.add("x",RPClass.BYTE);
Line 107 ⟶ 115:
objclass.add("!hdir",RPClass.STRING,RPClass.HIDDEN);
objclass.add("?kill",RPClass.FLAG);
</
== DONE TO HERE ==
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.
| |||