Class ExponentialExperienceCalculator
java.lang.Object
de.Keyle.MyPet.api.skill.experience.ExponentialExperienceCalculator
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublegetExpByLevel(Pet pet, int level) Computes the total cumulative experience required to reach the specified level.Returns a unique identifier for this calculator (e.g.longReturns a version number representing the current revision of this calculator's formula.booleanisUsable()Indicates whether this calculator is ready to produce results.
-
Constructor Details
-
ExponentialExperienceCalculator
public ExponentialExperienceCalculator()Creates a geometric curve.
-
-
Method Details
-
getExpByLevel
Description copied from interface:ExperienceCalculatorComputes the total cumulative experience required to reach the specified level.- Specified by:
getExpByLevelin interfaceExperienceCalculator- 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:ExperienceCalculatorReturns 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
ExperienceCachecan detect staleness and recalculate.- Specified by:
getVersionin interfaceExperienceCalculator- Returns:
- the formula's revision number
-
isUsable
public boolean isUsable()Description copied from interface:ExperienceCalculatorIndicates 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:
isUsablein interfaceExperienceCalculator- Returns:
trueifExperienceCalculator.getExpByLevel(de.Keyle.MyPet.api.entity.Pet, int)can be called safely
-
getIdentifier
Description copied from interface:ExperienceCalculatorReturns a unique identifier for this calculator (e.g."MyPet","Power").Used alongside
ExperienceCalculator.getVersion()to key the experience cache.- Specified by:
getIdentifierin interfaceExperienceCalculator- Returns:
- this calculator's unique identifier
-