Class RPWorld

java.lang.Object
marauroa.server.game.rp.RPWorld
All Implemented Interfaces:
Iterable<IRPZone>
Direct Known Subclasses:
PythonRPWorld, StendhalRPWorld

public class RPWorld extends Object implements Iterable<IRPZone>
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 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

      public static RPWorld 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

      public void addRPZone(IRPZone zone)
      Adds a new zone to World
      Parameters:
      zone - a zone to add to world.
    • getDefaultZone

      public IRPZone getDefaultZone()
      gets the default zone.
      Returns:
      default zone
    • setDefaultZone

      public void setDefaultZone(IRPZone defaultZone)
      sets the default zone
      Parameters:
      defaultZone - default zone
    • hasRPZone

      public boolean hasRPZone(IRPZone.ID zoneid)
      Returns true if world has such zone
      Parameters:
      zoneid - the zone to query
      Returns:
      true of the zone exists
    • getRPZone

      public IRPZone getRPZone(IRPZone.ID zoneid)
      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

      public IRPZone getRPZone(RPObject.ID objectid)
      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

      public IRPZone removeRPZone(IRPZone.ID zoneid) throws Exception
      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

      public IRPZone removeRPZone(RPObject.ID objectid) throws Exception
      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

      public void add(RPObject object)
      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

      public void requestSync(RPObject object)
      When a player is added to a zone, it needs his status to be synced.
      Parameters:
      object - the player object
    • get

      public RPObject get(RPObject.ID id)
      This method returns an object from a zone using it ID
      Parameters:
      id - the object's id
      Returns:
      the object
    • has

      public boolean has(RPObject.ID id)
      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

      public RPObject remove(RPObject.ID id)
      This method returns an object from a zone using it ID and remove it
      Parameters:
      id - the object's id
      Returns:
      the object or null if it not found.
    • iterator

      public Iterator<IRPZone> iterator()
      This method returns an iterator over all the zones contained.
      Specified by:
      iterator in interface Iterable<IRPZone>
      Returns:
      iterator over zones.
    • modify

      public void modify(RPObject object)
      This method notify zone that object has been modified. Used in Delta^2
      Parameters:
      object - the object that has been modified.
    • changeZone

      public void changeZone(IRPZone.ID newzoneid, RPObject object)
      This methods make a player/object to change zone.
      Parameters:
      newzoneid - the new zone id
      object - the object we are going to change zone to.
      Throws:
      RPObjectInvalidException
    • changeZone

      public void changeZone(String newzone, RPObject object)
      This methods make a player/object to change zone.
      Parameters:
      newzone - the new zone id
      object - 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.