Represents a boost manager that applies various effects to a base value. Typically used in combination with Attribute or Currency classes.

Constructors

Properties

addBoost: {
    (id: string, name: string, description: string, value: ((input: Decimal) => Decimal), order?: number): void;
    (boostObj: BoostsObjectInit | BoostsObjectInit[]): void;
} = ...

Type declaration

    • (id, name, description, value, order?): void
    • Sets or updates a boost with the given parameters.

      Parameters

      • id: string

        The ID of the boost.

      • name: string

        The name of the boost.

      • description: string

        The description of the boost.

      • value: ((input: Decimal) => Decimal)

        The value of the boost (function).

      • Optionalorder: number

        The order of the boost (lower order go first)

      Returns void

      Use the other overload instead.

      // Set a boost that multiplies the input value by 2
      boost.setBoost("doubleBoost", "Double Boost", "Doubles the input value", (input) => input.mul(2));
    • (boostObj): void
    • Sets or updates a boost with the given parameters.

      Parameters

      Returns void

      // Set a boost that multiplies the input value by 2
      boost.setBoost({
      id: "doubleBoost",
      name: "Double Boost",
      desc: "Doubles the input value",
      value: (input) => input.mul(2),
      });

setBoost

Use setBoost instead.

baseEffect: Decimal

The base effect value.

boostArray: BoostObject[]

An array of boost objects.

Methods

  • Calculates the cumulative effect of all boosts on the base effect.

    Parameters

    • base: DecimalSource = ...

      The base effect value to calculate with. Defaults to the base effect of the boost manager.

    Returns Decimal

    The calculated effect after applying boosts.

    // Calculate the effect of all boosts
    const finalEffect = boost.calculate();
  • Clears all boosts from the boost manager.

    Returns void

    // Clear all boosts
    boost.clearBoosts();
    // boostArray is now []
    // baseEffect is still the same
  • Gets a boost object by its ID.

    Parameters

    • id: string

      The ID of the boost to retrieve.

    Returns null | BoostObject

    The boost object if found, or null if not found.

    Use getBoosts instead.

  • Gets all boosts with the given ID.

    Parameters

    • id: string | RegExp

      A string or regular expression to match the ID of the boosts.

    Returns BoostObject[]

    An array of boost objects with the given ID, or a tuple of the array and the index of the boosts.

    // Get all boosts with the ID "healthBoost"
    const healthBoosts = boost.getBoosts("healthBoost");

    // Get all boosts with the ID "healthBoost" and their index
    const [healthBoosts, healthBoostIndexes] = boost.getBoosts("healthBoost", true);

    // Get all boosts with the ID "healthBoost" or "manaBoost"
    const healthAndManaBoosts = boost.getBoosts(/(health|mana)Boost/);
  • Parameters

    • id: string | RegExp
    • index: boolean

    Returns [BoostObject[], number[]]

  • Removes a boost by its ID. Only removes the first instance of the id.

    Parameters

    • id: string

      The ID of the boost to remove.

    Returns void

    // Remove the boost with the ID "healthBoost"
    boost.removeBoost("healthBoost");
  • Sets or updates a boost with the given parameters.

    Parameters

    • id: string

      The ID of the boost.

    • name: string

      The name of the boost.

    • description: string

      The description of the boost.

    • value: ((input: Decimal) => Decimal)

      The value of the boost (function).

    • Optionalorder: number

      The order of the boost (lower order go first)

    Returns void

    Use the other overload instead.

    // Set a boost that multiplies the input value by 2
    boost.setBoost("doubleBoost", "Double Boost", "Doubles the input value", (input) => input.mul(2));
  • Sets or updates a boost with the given parameters.

    Parameters

    Returns void

    // Set a boost that multiplies the input value by 2
    boost.setBoost({
    id: "doubleBoost",
    name: "Double Boost",
    desc: "Doubles the input value",
    value: (input) => input.mul(2),
    });