Class AttributeStatic<EnableBoost>

Represents a static attribute, which is number that can affected by boosts.

Note: This class is essentially a wrapper around Boost, and if you choose not to use boosts, you can use Decimal directly. It may be marked as deprecated in the future.

const health = new AttributeStatic(undefined, true, 100); // AttributeStatic<true>
// Set a health boost that multiplies the health by 1.1
health.boost.setBoost({
id: "healthBoost",
value: (e) => e.mul(1.1),
});
console.log(health.value); // 110

Type Parameters

  • EnableBoost extends boolean = true

    Indicates whether the boost is enabled. Defaults to true.

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

Constructors

  • Constructs a new instance of the Attribute class.

    Type Parameters

    • EnableBoost extends boolean = true

    Parameters

    • Optionalpointer: Pointer<Attribute>

      A function or an instance of the attribute class. Defaults to a new instance of the attribute class.

    • useBoost: EnableBoost = ...

      Indicates whether to use boost for the attribute. Defaults to true. (hint: if you don't use boost, don't use this class and use Decimal directly)

    • initial: DecimalSource = 0

      The initial value of the attribute. Defaults to 0.

    Returns AttributeStatic<EnableBoost>

Properties

boost: EnableBoost extends true
    ? Boost
    : null

The boost of the attribute. NOTE: This will not be used if the boost is disabled.

initial: Decimal

The initial value of the attribute.

pointerFn: (() => Attribute)

The data for the attribute.

Accessors

  • get value(): Decimal
  • Gets the value of the attribute, and also updates the value stored. NOTE: This getter must be called every time the boost is updated, else the value stored will not be updated.

    Returns Decimal

    The calculated value of the attribute.

  • set value(value): void
  • Sets the value of the attribute. NOTE: This setter should not be used when boost is enabled.

    Parameters

    • value: Decimal

      The value to set the attribute to.

    Returns void

Methods

  • Updates the value of the attribute. NOTE: This method must be called every time the boost is updated, else the value stored will not be updated.

    Returns void

    This is automatically called when the value is accessed. It will be removed in the future.