Interface AdvancementService

All Known Implementing Classes:
StandardAdvancementService

public interface AdvancementService
Provides logic to advance a Profile through a Mission.
  • Method Details

    • startMission

      Progress startMission(Profile profile, String missionNameOrId)
      Begins a Mission by assigning and creating a new instance of Progress. This is shorthand for looking up a mission by name (Mission.getName()), setting the Profile and saving to the database.
      Parameters:
      profile - the Profile of the person starting the mission
      missionNameOrId - the unique name of the Mission, as determined by Mission.getName()
    • advanceProgress

      Progress advanceProgress(Profile profile, String missionNameOrId, int amount)
      Advances Progress by decrementing the value specified by the amount, and returning the prizes rewarded in the form of an Advancement object. Specifically, this will involve the follwing operations:
      • If the Profile has no Progress for the supplied mission, then there shall be no side-effects.
      • Otherwise, decrement the value tracked by Progress.getRemaining() using the specified amount
      • If, after subtraction, the result is <= 0 advance to the next Step in the Mission
      • Carry over any remaining actions to the next step.
      • Continue rewarding Reward instances until all actions are consumed
      • Continue tracking complete Steps until all actions are consumed
      Additionally, the operation must be performed atomically without fear of race conditions.
      Parameters:
      profile - the Profile tracking the Mission
      missionNameOrId - the Mission's name as determined by Mission.getName().
      amount - the amount of actions to apply to the Progress.getRemaining()
      Returns:
      the Advancement, never null