Interface IRPRuleProcessor

All Known Implementing Classes:
PythonRPRuleProcessor, RPRuleProcessorImpl, StendhalRPRuleProcessor

public interface IRPRuleProcessor
Interface for the class that is in charge of executing actions. Implement it to personalize the game

Important: you must implement the method
public static IRPRuleProcessor get().

This interface is the key to extend Marauroa to match your game needs. First we have setContext that allows us complete access to RP Server Manager, so we can control some things like disconnect players or send them stuff. It is not possible to access GameServerManager or NetworkServerManager directly to avoid incorrect manipulation of data structures that could place the server in a bad state.

onActionAdd, execute, beginTurn and endTurn allow you to code behaviour for each of these events. You can control whenever to allow player to add an action to system, what system should do when it receive an action and what to do at the begin and end of each turn.
Perceptions are delivered just after endTurn is called.

Also your game can handle what to do at player entering, player leaving and decide what to do when player timeouts because connection has been dropped for example.

  • Method Details

    • setContext

      void setContext(RPServerManager rpman)
      Set the context where the actions are executed.
      Parameters:
      rpman - the RPServerManager object that is running our actions
    • checkGameVersion

      boolean checkGameVersion(String game, String version)
      Returns true if the version of the game is compatible
      Parameters:
      game - the game name
      version - the game version
      Returns:
      true if game,version is compatible
    • createAccount

      AccountResult createAccount(String username, String password, String email)
      Creates an account for the game
      Parameters:
      username - the username who is going to be added.
      password - the password for our username.
      email - the email of the player for notifications or password reminders.
      Returns:
      the Result of creating the account.
    • createAccountWithToken

      AccountResult createAccountWithToken(String username, String tokenType, String token)
      Create an account for a player in game. Uses token instead of password for cases like 3rd party authentication (e.g. google sign-in).
      Parameters:
      username - username for a new account
      tokenType - token type for useful data about token
      token - auth token to verify, usually obtained from 3rd party
      Returns:
      the Result of creating a new account
    • createCharacter

      CharacterResult createCharacter(String username, String character, RPObject template)
      Creates an new character for an account already logged into the game
      Parameters:
      username - the username who owns the account of the character to be added.
      character - the character to create
      template - the desired values of the avatar representing the character.
      Returns:
      the Result of creating the character.
    • onActionAdd

      boolean onActionAdd(RPObject object, RPAction action, List<RPAction> actionList)
      This method is called *before* adding an action by RPScheduler so you can choose not to allow the action to be added by returning false
      Parameters:
      object - the object that casted the action
      action - the action that is going to be added.
      actionList - the actions that this player already owns.
      Returns:
      true if we approve the action to be added.
    • execute

      void execute(RPObject object, RPAction action)
      Execute an action in the name of a player.
      Parameters:
      object - the object that executes
      action - the action to execute
    • beginTurn

      void beginTurn()
      Notify it when a begin of actual turn happens.
    • endTurn

      void endTurn()
      Notify it when a end of actual turn happens.
    • onInit

      boolean onInit(RPObject object) throws RPObjectInvalidException
      Callback method called when a new player enters in the game
      Parameters:
      object - the new player that enters in the game.
      Returns:
      true if object has been added.
      Throws:
      RPObjectInvalidException - if the object was not accepted
    • onExit

      boolean onExit(RPObject object) throws RPObjectNotFoundException
      Callback method called when a player exits the game
      Parameters:
      object - the new player that exits the game.
      Returns:
      true to allow player to exit
      Throws:
      RPObjectNotFoundException - if the object was not found
    • onTimeout

      void onTimeout(RPObject object) throws RPObjectNotFoundException
      Callback method called when a new player time out. This method MUST logout the player
      Parameters:
      object - the new player that timeouts.
      Throws:
      RPObjectNotFoundException - if the object was not found
    • getMimeTypeForResource

      String getMimeTypeForResource(String resource)
      gets the content type for the requested resource
      Parameters:
      resource - name of resource
      Returns:
      mime content/type or null
    • getResource

      InputStream getResource(String resource)
      gets an input stream to the requested resource
      Parameters:
      resource - name of resource
      Returns:
      InputStream or null