module

Library: Active Effect Manager

Endorsements
0
Installs
5.87%
Comments
0
Latest version0.2.4
Minimum Core9
Compatible Core9
Last updated11 months ago
Created1 year ago
Authors
Languages English
Français
Systems All systems
Dependencies Warp Gate
socketlib
Project source Project URL
Report bugs Bug tracker URL
Read-me Readme URL
Changelog Changelog URL

FoundryVTT Library: Active Effect Manager

A library for leverage and synchronize the creation/update/delete of Active Effects .

The library was born as a series of functions for integration with the "DFreds Convenient Effects" module and utilities in a multi-system context outside Dnd5e. After extensively testing it with different modules i decide to get better feedback from the community and in preparation for FVTT10 to separate it this part of the code from the projects to use it as a support library.

Translation status

Include as a dependency in your manifest

{
    "name": "active-effect-manager-lib",
    "type": "module",
    "manifest": "https://github.com/p4535992/foundryvtt-active-effect-manager-lib/releases/latest/download/module.json"
}

NOTE: If you are a javascript developer and not a typescript developer, you can just use the javascript files under the dist folder

NOTE

In compliance with the licenses, some piece of code of some feature has been inserted by other projects that I describe in detail in the "Credits" department of this README, I invite you to support these developers.

My aim is not to take credit for their work, I just don't want to install 100 modules for 100 features which then collide with each other, every single external feature can be disabled in the settings of this module to allow the use of modules between them .

Installation

It's always easiest to install modules from the in game add-on browser.

To install this module manually:

  1. Inside the Foundry "Configuration and Setup" screen, click "Add-on Modules"
  2. Click "Install Module"
  3. In the "Manifest URL" field, paste the following url: https://raw.githubusercontent.com/p4535992/foundryvtt-active-effect-manager-lib/master/src/module.json
  4. Click 'Install' and wait for installation to complete
  5. Don't forget to enable the module in game using the "Manage Module" button

libWrapper

This module uses the libWrapper library for wrapping core methods. It is a hard dependency and it is recommended for the best experience and compatibility with other modules.

socketlib

This module uses the socketlib library for wrapping core methods. It is a hard dependency and it is recommended for the best experience and compatibility with other modules.

Features

Feature: Enable the extended status effect name hud interaction

Custom integration for multysistem of Adding and Removing Status Effects of Dfreds convinient effect any credits for this feature is given to DFreds

This will extend the funcionality of the standard status effect name.

Once enabled, right click on any effect in the status effect panel application and select Toggle Status Effect to add or remove the effect from the list.

Conflict: You should not use this and Combat Utility Belt's "Enhanced Conditions" at the same time, as multiple modules replacing/adding to the available status effects can cause conflicts.

Feature: Shy Effects

Custom integration for multysistem of Shy Effects any credits for this feature is given to Kandashi

This module will disable any active effect icons that do not come from an "Owned source". This level of control can be configured from the module settings. A user requires X permissions on a source item/actor to view the active effects created by that item.

Feature: Fathomless

Custom integration for multysistem of Fathomless - Proof of Concept any credits for this feature is given to schultzcole

This feature allow active effect changes to depend on actor data, even actor data that is modified by other active effects, so long as there are no cyclical dependencies.

This feature allows active effect changes to depend on other actor data, even actor data that is modified by other active effects. This is accomplished by constructing a directed graph that encapsulates the dependency relationships between actor properties, then using that graph to perform a Topological Sort in order to apply the effect changes in the correct order so that all dependencies are taken into account.

The nature of this implementation is such that any changes "downstream" of an actor property that is involved in a dependency cycle are ignored.

Referencing an actor property in an effect change is done with the syntax &my.actor.property.path. Note the use of & rather than @, which is deliberate (see the related caveat below).

Feature: Drop Effects on Items

Custom integration from Drop Effects on Items

With it enabled, creating duplicate effects between different items (e.g. "Poisoned" for various weapons or spells which inflict that condition) is as simple as dragging and dropping from one to the next. It also allows the application of item effects onto actors from the item sheet directly.

Feature: Drop Effects on Actors

Custom integration from DFreds Convenient Effects

With it enabled, creating duplicate effects between different actors (e.g. "Poisoned" for various weapons or spells which inflict that condition) is as simple as dragging and dropping from one to the next.

Feature: Quick status effect

Custom integration from Quick status effect

Quickly select effects for a token or tokens by replacing the built-in status effect selector with an auto-complete-esque search box and filtered list.

API (WORKING IN PROGRESS...)

API Index

  addEffectOnActor(
    actorId: string,
    effectName: string,
    effect: Effect,
  ): Promise<Item | ActiveEffect | boolean | undefined>;

  findEffectByNameOnActor(
    actorId: string,
    effectName: string): Promise<ActiveEffect | undefined>;

  hasEffectAppliedOnActor(
    actorId: string,
    effectName: string,
    includeDisabled: boolean): Promise<boolean | undefined>;

  hasEffectAppliedFromIdOnActor(
    actorId: string,
    effectId: string,
    includeDisabled: boolean,
  ): Promise<boolean | undefined>;

  toggleEffectFromIdOnActor(
    actorId: string,
    effectId: string,
    alwaysDelete: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
  ): Promise<boolean | undefined>;

  addActiveEffectOnActor(
    actorId: string,
    activeEffectData: ActiveEffectData): Promise<ActiveEffect | undefined>;

  removeEffectOnActor(
    actorId: string,
    effectName: string): Promise<ActiveEffect | undefined>;

  removeEffectFromIdOnActor(
    actorId: string,
    effectId: string): Promise<ActiveEffect | undefined>;

  addEffectOnToken(
    tokenId: string,
    effectName: string,
    effect: Effect): Promise<ActiveEffect | undefined>;

  findEffectByNameOnToken(
    tokenId: string,
    effectName: string): Promise<ActiveEffect | undefined>;

  hasEffectAppliedOnToken(
    tokenId: string,
    effectName: string,
    includeDisabled: boolean): Promise<boolean | undefined>;

  hasEffectAppliedFromIdOnToken(
    tokenId: string,
    effectId: string,
    includeDisabled: boolean,
  ): Promise<boolean | undefined>;

  toggleEffectFromIdOnToken(
    tokenId: string,
    effectId: string,
    alwaysDelete: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
  ): Promise<boolean | undefined>;

  toggleEffectFromDataOnToken(
    tokenId: string,
    effect: Effect,
    alwaysDelete: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
  ): Promise<boolean | undefined>;

  addActiveEffectOnToken(
    tokenId: string,
    activeEffectData: ActiveEffectData): Promise<ActiveEffect | undefined>;

  removeEffectOnToken(
    tokenId: string,
    effectName: string): Promise<ActiveEffect | undefined>;

  removeEffectFromIdOnToken(
    tokenId: string,
    effectId: string): Promise<ActiveEffect | undefined>;

  removeEffectFromIdOnTokenMultiple(
    tokenId: string,
    effectIds: string[]): Promise<ActiveEffect | undefined>;

  updateEffectFromIdOnToken(
    tokenId: string,
    effectId: string,
    origin: string,
    overlay: boolean,
    effectUpdated: Effect,
  ): Promise<boolean | undefined>;

  updateEffectFromNameOnToken(
    tokenId: string,
    effectName: string,
    origin: string,
    overlay: boolean,
    effectUpdated: Effect,
  ): Promise<boolean | undefined>;

  updateActiveEffectFromIdOnToken(
    tokenId: string,
    effectId: string,
    origin: string,
    overlay: boolean,
    effectUpdated: ActiveEffectData,
  ): Promise<boolean | undefined>;

  updateActiveEffectFromNameOnToken(
    tokenId: string,
    effectName: string,
    origin: string,
    overlay: boolean,
    effectUpdated: ActiveEffectData,
  ): Promise<boolean | undefined>;

  onManageActiveEffectFromEffectId(
    effectActions: {
      create: 'create';
      edit: 'edit';
      delete: 'delete';
      toogle: 'toggle';
      update: 'update';
    },
    owner: Actor | Item,
    effectId: string,
    alwaysDelete?: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
    isTemporary?: boolean,
    isDisabled?: boolean,
  ): Promise<Item | ActiveEffect | boolean | undefined>;

  onManageActiveEffectFromEffect(
    effectActions: {
      create: 'create';
      edit: 'edit';
      delete: 'delete';
      toogle: 'toggle';
      update: 'update';
    },
    owner: Actor | Item,
    effect: Effect,
    alwaysDelete?: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
    isTemporary?: boolean,
    isDisabled?: boolean,
  ): Promise<Item | ActiveEffect | boolean | undefined>;

  onManageActiveEffectFromActiveEffect(
    effectActions: {
      create: 'create';
      edit: 'edit';
      delete: 'delete';
      toogle: 'toggle';
      update: 'update';
    },
    owner: Actor | Item,
    activeEffect: ActiveEffect | null | undefined,
    alwaysDelete?: boolean,
    forceEnabled?: boolean,
    forceDisabled?: boolean,
    isTemporary?: boolean,
    isDisabled?: boolean,
  ): Promise<Item | ActiveEffect | boolean | undefined>;

async game.modules.get('active-effect-manager-lib').api.xxx() ⇒ Promise.<void>

The effect object structer is the following:

{
    customId: string
    name: string
    description: string
    icon: string
    tint: string
    seconds: number
    rounds: number
    turns: number
    isDynamic: boolean
    isViewable: boolean
    isDisabled: boolean
    isTemporary: boolean
    isSuppressed: boolean
    flags = {},
    changes = ActiveEffectChangeData[],
    atlChanges = ActiveEffectChangeData[],
    tokenMagicChanges = ActiveEffectChangeData[],
    nestedEffects = Effect[],
    transfer: boolean
    atcvChanges = ActiveEffectChangeData[],
    dae = {},
    overlay: boolean
}
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x