Class RPScheduler

java.lang.Object
marauroa.server.game.rp.RPScheduler

public class RPScheduler extends Object
This class represents a scheduler to deliver action by turns, so every action added to the scheduler is executed on the next turn. Each object can cast as many actions as it wants.

We have two turns: actual and next one.
When we execute actions on actual turn, next turn become actual turn and the process repeat.

  • Constructor Details

    • RPScheduler

      public RPScheduler()
      Constructor
  • Method Details

    • addRPAction

      public boolean addRPAction(RPObject object, RPAction action, IRPRuleProcessor ruleProcessor)
      Add an RPAction to the scheduler for the next turn
      Parameters:
      object - the object that casted the action.
      action - the RPAction to add.
      ruleProcessor - where the actions are going to checked.
      Returns:
      true, if the action was added successfully, false otherwise
    • clearRPActions

      public void clearRPActions(RPObject object)
      This method clears the actions that may exist in actual turn or the next one for the giver object id.
      Parameters:
      object - object to remove actions from.
    • visit

      public void visit(IRPRuleProcessor ruleProcessor)
      For each action in the actual turn, make it to be run in the ruleProcessor.
      Parameters:
      ruleProcessor - the class that really run the action.
    • nextTurn

      public void nextTurn()
      This method moves to the next turn and deletes all the actions in the actual turn