Skip to content

Commit

Permalink
fix(resolver): allow custom fallback ID effects
Browse files Browse the repository at this point in the history
Add a missing step to the effect resolution flow. If a user has no
custom effect defined by name/LID, and the module does not define an
effect by LID, allow the user to define a custom effect by fallback ID
before finally resorting to the module's effect for that fallback ID.
  • Loading branch information
cirrahn committed Jul 25, 2024
1 parent 1656869 commit 99dee7e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/effectResolver/effectResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const _getCustomMacroUuid_itemName = ({ itemName, customEffects }) => {
return macroUuid;
};

const _getCustomMacroUuid = (itemLid, itemName) => {
const _getCustomMacroUuid = (itemLid, itemName = null) => {
const customEffects = (game.settings.get(MODULE_ID, SETTING_EFFECTS_MANAGER_STATE) || {}).effects;
if (!customEffects || !Object.keys(customEffects).length) return null;

Expand Down Expand Up @@ -89,12 +89,23 @@ export const pGetMacroUuid = async (itemLid, itemName, fallbackActionIdentifier)
return customUuid;
}

// Resolve specific effects defined by the module
const lwfxUuid = await _pGetLwfxMacroUuid(weaponEffects[itemLid]);
if (lwfxUuid) {
console.log(`Lancer Weapon FX | Found macro "${lwfxUuid}" for Lancer ID "${itemLid}"`);
return lwfxUuid;
}

// Resolve custom macros bound on fallback "fake LID"s
const customFallbackUuid = await _getCustomMacroUuid(fallbackActionIdentifier, null);
if (customFallbackUuid) {
console.log(
`Lancer Weapon FX | Found custom macro "${customFallbackUuid}" for fallback identifier "${fallbackActionIdentifier}"`,
);
return customFallbackUuid;
}

// Resolve fallback effects defined by the module
const lwfxFallbackUuid = await _pGetLwfxMacroUuid(weaponEffects[fallbackActionIdentifier]);
if (lwfxFallbackUuid) {
console.log(
Expand Down

0 comments on commit 99dee7e

Please sign in to comment.