Package marauroa.server.game.rp
Class RPWorld
java.lang.Object
marauroa.server.game.rp.RPWorld
- Direct Known Subclasses:
PythonRPWorld
,StendhalRPWorld
This class is a container of RPZones.
Worlds in Marauroa can be so big, so huge, that we need to split them in to several pieces. Each of these pieces are what we call an IRPZone.
So our world is made of several IRPZones that are independent of each other.
RPWorld provides onInit and onFinish methods that are called on server
initialisation and server finalization to define what to do with the world on
these events.
There is no default behaviour and you need to extend this class to
implement the behaviour.
- Author:
- miguel
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
This method adds an object to the zone it points with its zoneid attribute.void
Adds a new zone to Worldvoid
changeZone(String newzone, RPObject object)
This methods make a player/object to change zone.void
changeZone(IRPZone.ID newzoneid, RPObject object)
This methods make a player/object to change zone.static RPWorld
get()
Returns an unique World method.get(RPObject.ID id)
This method returns an object from a zone using it IDgets the default zone.getRPZone(IRPZone.ID zoneid)
Returns the zone or null if it doesn't existsgetRPZone(RPObject.ID objectid)
Returns the zone or null if it doesn't existsboolean
has(RPObject.ID id)
This method returns true if an object exists in a zone using it IDboolean
hasRPZone(IRPZone.ID zoneid)
Returns true if world has such zoneprotected void
Initialize the player entry container so RPWorld knows about players.iterator()
This method returns an iterator over all the zones contained.void
This method notify zone that object has been modified.void
nextTurn()
This method make world to move to the next turn, calling each zone nextTurn method.void
onFinish()
This method is called when server is going to shutdown.void
onInit()
This method is called when RPWorld is created by RPServerManagerremove(RPObject.ID id)
This method returns an object from a zone using it IDremoveRPZone(IRPZone.ID zoneid)
Removes a zone from world.removeRPZone(RPObject.ID objectid)
Removes a zone from world.void
requestSync(RPObject object)
When a player is added to a zone, it needs his status to be synced.void
setDefaultZone(IRPZone defaultZone)
sets the default zoneint
size()
This methods return the amount of objects added to world.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RPWorld
protected RPWorld()creates a new RPWorld. Note this class is designed as a singleton.
-
-
Method Details
-
initialize
protected void initialize()Initialize the player entry container so RPWorld knows about players. -
get
Returns an unique World method.- Returns:
- an instance of RPWorld
-
onInit
public void onInit()This method is called when RPWorld is created by RPServerManager -
onFinish
public void onFinish()This method is called when server is going to shutdown. -
addRPZone
Adds a new zone to World- Parameters:
zone
- a zone to add to world.
-
getDefaultZone
gets the default zone.- Returns:
- default zone
-
setDefaultZone
sets the default zone- Parameters:
defaultZone
- default zone
-
hasRPZone
Returns true if world has such zone- Parameters:
zoneid
- the zone to query- Returns:
- true of the zone exists
-
getRPZone
Returns the zone or null if it doesn't exists- Parameters:
zoneid
- the zone to query- Returns:
- the zone or null if it is not found.
-
getRPZone
Returns the zone or null if it doesn't exists- Parameters:
objectid
- an id of an object that is in the zone to query- Returns:
- the zone or null if it is not found.
-
removeRPZone
Removes a zone from world. It calls zone.onFinish method to free resources zone could have allocated. *- Parameters:
zoneid
-- Returns:
- the zone removed or null if not found
- Throws:
Exception
- caused by onFinish
-
removeRPZone
Removes a zone from world. It calls zone.onFinish method to free resources zone could have allocated.- Parameters:
objectid
-- Returns:
- the zone removed or null if not found
- Throws:
Exception
- caused by onFinish
-
add
This method adds an object to the zone it points with its zoneid attribute. And if it is a player, it request also a sync perception.- Parameters:
object
- the object to add
-
requestSync
When a player is added to a zone, it needs his status to be synced.- Parameters:
object
- the player object
-
get
This method returns an object from a zone using it ID- Parameters:
id
- the object's id- Returns:
- the object
-
has
This method returns true if an object exists in a zone using it ID- Parameters:
id
- the object's id- Returns:
- true if the object exists
-
remove
This method returns an object from a zone using it ID- Parameters:
id
- the object's id- Returns:
- the object or null if it not found.
-
iterator
This method returns an iterator over all the zones contained. -
modify
This method notify zone that object has been modified. Used in Delta^2- Parameters:
object
- the object that has been modified.
-
changeZone
This methods make a player/object to change zone.- Parameters:
newzoneid
- the new zone idobject
- the object we are going to change zone to.- Throws:
RPObjectInvalidException
-
changeZone
This methods make a player/object to change zone.- Parameters:
newzone
- the new zone idobject
- the object we are going to change zone to.
-
nextTurn
public void nextTurn()This method make world to move to the next turn, calling each zone nextTurn method. * -
size
public int size()This methods return the amount of objects added to world.- Returns:
- the amount of objects added to world.
-