Class PowerExperienceCalculator
java.lang.Object
de.Keyle.MyPet.api.skill.experience.PowerExperienceCalculator
- All Implemented Interfaces:
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 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
-
PowerExperienceCalculator
public PowerExperienceCalculator()Creates a polynomial 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
-