Class ExponentialExperienceCalculator

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

public class ExponentialExperienceCalculator extends Object implements ExperienceCalculator
Geometric experience curve: each level l costs Base * Growth^(l-1), summed from level 1 up to the target. A growth of 1 degrades to a flat ramp; values above 1 make each level progressively more expensive than the last. The cumulative sum has a closed form (geometric series), so no per-level loop is needed.

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

  • Constructor Details

    • ExponentialExperienceCalculator

      public ExponentialExperienceCalculator()
      Creates a geometric 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