Class SteppedScaling
java.lang.Object
io.artificial.enchantments.api.scaling.SteppedScaling
- All Implemented Interfaces:
LevelScaling
Stepped scaling algorithm with linear interpolation between defined levels.
This scaling pattern allows defining exact values at specific levels, with values between steps being linearly interpolated. This is useful for enchantments that need specific breakpoints or custom progression curves.
Behavior:
- If level is exactly defined in steps, return that value
- If level is between two defined steps, linearly interpolate
- If level exceeds the highest step, use the maximum step value
Example: Mapping level 1->5.0, level 5->10.0, level 10->15.0 would produce: 5.0, 6.25, 7.5, 8.75, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 15.0, ...
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionSteppedScaling(@NotNull Map<Integer, Double> steps) Creates a new stepped scaling from a map of level-value pairs. -
Method Summary
-
Constructor Details
-
SteppedScaling
Creates a new stepped scaling from a map of level-value pairs.The map must not be empty and must contain a value for level 1. The steps are sorted by level for efficient lookup.
- Parameters:
steps- map of level -> value pairs (must not be empty, must include level 1)- Throws:
IllegalArgumentException- if steps is empty or missing level 1
-
-
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
-
getSteps
Gets an unmodifiable view of the defined steps.- Returns:
- map of level -> value pairs (unmodifiable)
- Since:
- 0.1.0
-
toString
-