Interface ExperienceCalculator
- All Known Implementing Classes:
DefaultExperienceCalculator,ExponentialExperienceCalculator,LinearExperienceCalculator,PowerExperienceCalculator
Implementations define the XP curve that determines how quickly a pet progresses
through levels. The plugin ships with DefaultExperienceCalculator plus the
config-tunable Linear/Power/Exponential curves; further calculators
can be registered through the ExperienceCalculatorManager.
Each calculator is identified by a unique string (getIdentifier()) and a
numeric version (getVersion()). Together these allow the ExperienceCache
to detect when the formula has changed and invalidate stale cached values.
-
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.
-
Method Details
-
getExpByLevel
Computes the total cumulative experience required to reach the specified level.- 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
long getVersion()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
ExperienceCachecan detect staleness and recalculate.- Returns:
- the formula's revision number
-
isUsable
boolean isUsable()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.
- Returns:
trueifgetExpByLevel(de.Keyle.MyPet.api.entity.Pet, int)can be called safely
-
getIdentifier
String getIdentifier()Returns a unique identifier for this calculator (e.g."MyPet","Power").Used alongside
getVersion()to key the experience cache.- Returns:
- this calculator's unique identifier
-