Class DiminishingScaling
java.lang.Object
io.artificial.enchantments.api.scaling.DiminishingScaling
- All Implemented Interfaces:
LevelScaling
A scaling algorithm that approaches a maximum value with diminishing returns.
The formula is max * (level / (level + factor)), meaning each
additional level provides a smaller increase than the previous one.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionDiminishingScaling(double maxValue, double scalingFactor) Creates a new diminishing scaling. -
Method Summary
-
Constructor Details
-
DiminishingScaling
public DiminishingScaling(double maxValue, double scalingFactor) Creates a new diminishing scaling.- Parameters:
maxValue- the asymptotic maximum value (must be positive)scalingFactor- the factor controlling return diminishment (must be positive)- Throws:
IllegalArgumentException- if either parameter is not positive
-
-
Method Details
-
calculate
public double calculate(int level) Description copied from interface:LevelScalingCalculates the scaled value for a given enchantment level.- Specified by:
calculatein interfaceLevelScaling- Parameters:
level- the enchantment level (>= 1)- Returns:
- the calculated value
-
getMaxValue
public double getMaxValue()Gets the maximum asymptotic value.- Returns:
- the max value
-
getScalingFactor
public double getScalingFactor()Gets the scaling factor.- Returns:
- the scaling factor
-
toString
-