remove warpgate active effect handling from power management
This commit is contained in:
@@ -132,17 +132,6 @@ export class PowerEffect {
|
||||
|
||||
async applyActiveEffects(token, effectDocuments) {
|
||||
await token.actor.createEmbeddedDocuments('ActiveEffect', effectDocuments);
|
||||
// const mutation = {
|
||||
// embedded: { ActiveEffect: {} },
|
||||
// };
|
||||
// const mutateOptions = {
|
||||
// permanent: true,
|
||||
// description: `${this.source.name} applying ${effectDocuments[effectDocuments.length - 1]?.name} to ${token.name}`,
|
||||
// };
|
||||
// for (const effectDocument of effectDocuments) {
|
||||
// mutation.embedded.ActiveEffect[effectDocument.name] = effectDocument;
|
||||
// }
|
||||
// await warpgate.mutate(token.document, mutation, {}, mutateOptions);
|
||||
}
|
||||
|
||||
get name() {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* globals warpgate */
|
||||
import { moduleName } from '../globals.js';
|
||||
import { ArcaneProtectionEffect } from './arcaneProtection.js';
|
||||
import { BanishEffect } from './banish.js';
|
||||
@@ -54,27 +53,17 @@ export async function powerEffectManagementHook(effect, data, userId) {
|
||||
if (!maintId) {
|
||||
return;
|
||||
}
|
||||
const mutateOptions = {
|
||||
permanent: true,
|
||||
comparisonKeys: {
|
||||
ActiveEffect: 'id',
|
||||
},
|
||||
};
|
||||
const targetIds = effect.getFlag(moduleName, 'targetIds') || [];
|
||||
for (const targetId of targetIds) {
|
||||
const mutation = {
|
||||
embedded: { ActiveEffect: {} },
|
||||
};
|
||||
const target = canvas.tokens.get(targetId);
|
||||
if (!target) {
|
||||
continue;
|
||||
}
|
||||
const effects = target.actor.effects.filter((e) => e.getFlag(moduleName, 'maintId') === maintId);
|
||||
for (const efct of effects) {
|
||||
mutation.embedded.ActiveEffect[efct.id] = warpgate.CONST.DELETE;
|
||||
const effectIds = target.actor.effects.filter((e) => e.getFlag(moduleName, 'maintId') === maintId).map((e) => e.id);
|
||||
if (effectIds.length === 0) {
|
||||
continue;
|
||||
}
|
||||
mutateOptions.description = `${effect.parent.name} is no longer ${effect.name} on ${target.name}`;
|
||||
await warpgate.mutate(target.document, mutation, {}, mutateOptions);
|
||||
await target.actor.deleteEmbeddedDocuments('ActiveEffects', effectIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user