Class LinearScaling

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

public final class LinearScaling extends Object implements LevelScaling
Linear scaling algorithm: base + (level - 1) * increment.

This is the most common scaling pattern, used by vanilla enchantments like Sharpness. Each level adds a constant amount to the base value.

Formula: value = base + (level - 1) * increment

Example: Sharpness adds 0.5 damage per level, starting at 1.0 for level 1: base=1.0, increment=0.5 produces values 1.0, 1.5, 2.0, 2.5, etc.

Since:
0.1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    LinearScaling(double base, double increment)
    Creates a new linear scaling with the specified base and increment.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    calculate(int level)
    Calculates the scaled value for a given enchantment level.
    double
    Gets the base value at level 1.
    double
    Gets the increment added per level.
    @NotNull String
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • LinearScaling

      public LinearScaling(double base, double increment)
      Creates a new linear scaling with the specified base and increment.
      Parameters:
      base - the value at level 1
      increment - the amount added per additional level
  • 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
    • getBase

      public double getBase()
      Gets the base value at level 1.
      Returns:
      the base value
      Since:
      0.1.0
    • getIncrement

      public double getIncrement()
      Gets the increment added per level.
      Returns:
      the increment value
      Since:
      0.1.0
    • toString

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