Class DiminishingScaling

java.lang.Object
io.artificial.enchantments.api.scaling.DiminishingScaling
All Implemented Interfaces:
LevelScaling

public final class DiminishingScaling extends Object implements 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 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: LevelScaling
      Calculates the scaled value for a given enchantment level.
      Specified by:
      calculate in interface LevelScaling
      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

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object