Class PowerExperienceCalculator

java.lang.Object
de.Keyle.MyPet.api.skill.experience.PowerExperienceCalculator
All Implemented Interfaces:
ExperienceCalculator

public class PowerExperienceCalculator extends Object implements ExperienceCalculator
Polynomial experience curve: each level l costs Factor * l^Exponent, summed from level 1 up to the target. An exponent of 1 degrades to a linear ramp; higher exponents accelerate the cost. There is no closed form for an arbitrary real exponent, so the sum is computed iteratively (bounded by the level cap and cached by ExperienceCache).

Parameters are read live from MyPetGlobal.LevelSystem.Curve so an admin edit followed by /mypet reload invalidates the ExperienceCache.

  • Constructor Details

    • PowerExperienceCalculator

      public PowerExperienceCalculator()
      Creates a polynomial curve.
  • Method Details

    • getExpByLevel

      public double getExpByLevel(Pet pet, int level)
      Description copied from interface: ExperienceCalculator
      Computes the total cumulative experience required to reach the specified level.
      Specified by:
      getExpByLevel in interface ExperienceCalculator
      Parameters:
      pet - the pet whose level curve is being calculated (allows per-type curves)
      level - the target level (1-based; level 1 typically requires 0 experience)
      Returns:
      the total experience required to reach level
    • getVersion

      public long getVersion()
      Description copied from interface: ExperienceCalculator
      Returns a version number representing the current revision of this calculator's formula.

      If the formula changes (for example, an admin edits the JavaScript source), the version must increment so the ExperienceCache can detect staleness and recalculate.

      Specified by:
      getVersion in interface ExperienceCalculator
      Returns:
      the formula's revision number
    • isUsable

      public boolean isUsable()
      Description copied from interface: ExperienceCalculator
      Indicates whether this calculator is ready to produce results.

      A calculator might be unusable if, for example, its backing script failed to compile or a required dependency is missing.

      Specified by:
      isUsable in interface ExperienceCalculator
      Returns:
      true if ExperienceCalculator.getExpByLevel(de.Keyle.MyPet.api.entity.Pet, int) can be called safely
    • getIdentifier

      public String getIdentifier()
      Description copied from interface: ExperienceCalculator
      Returns a unique identifier for this calculator (e.g. "MyPet", "Power").

      Used alongside ExperienceCalculator.getVersion() to key the experience cache.

      Specified by:
      getIdentifier in interface ExperienceCalculator
      Returns:
      this calculator's unique identifier