Add drag & drop support for effects between different sheets
Also refactor some effect related functionality into the DS4ActiveEffect class
This commit is contained in:
parent
b1d0810100
commit
1e7368875c
5 changed files with 60 additions and 29 deletions
|
@ -6,7 +6,6 @@
|
|||
import { ModifiableDataBaseTotal } from "../common/common-data";
|
||||
import { DS4 } from "../config";
|
||||
import { getGame } from "../helpers";
|
||||
import { DS4Item } from "../item/item";
|
||||
import { DS4ArmorDataProperties, DS4ShieldDataProperties } from "../item/item-data-properties";
|
||||
import { ItemType } from "../item/item-data-source";
|
||||
import { createCheckRoll } from "../rolls/check-factory";
|
||||
|
@ -85,20 +84,16 @@ export class DS4Actor extends Actor {
|
|||
applyActiveEffectsFiltered(predicate: (change: foundry.data.ActiveEffectData["changes"][number]) => boolean): void {
|
||||
const overrides: Record<string, unknown> = {};
|
||||
|
||||
// Organize non-disabled effects by their application priority
|
||||
// Organize non-disabled and -surpressed effects by their application priority
|
||||
const changes: (foundry.data.ActiveEffectData["changes"][number] & { effect: ActiveEffect })[] =
|
||||
this.effects.reduce(
|
||||
(changes: (foundry.data.ActiveEffectData["changes"][number] & { effect: ActiveEffect })[], e) => {
|
||||
if (e.data.disabled) return changes;
|
||||
const item = this.getOriginatingItemOfActiveEffect(e);
|
||||
if (item?.isNonEquippedEuipable()) return changes;
|
||||
|
||||
const factor = item?.activeEffectFactor ?? 1;
|
||||
if (e.data.disabled || e.isSurpressed) return changes;
|
||||
|
||||
const newChanges = e.data.changes.filter(predicate).flatMap((c) => {
|
||||
const changeSource = c.toObject();
|
||||
changeSource.priority = changeSource.priority ?? changeSource.mode * 10;
|
||||
return Array(factor).fill({ ...changeSource, effect: e });
|
||||
return Array(e.factor).fill({ ...changeSource, effect: e });
|
||||
});
|
||||
|
||||
return changes.concat(newChanges);
|
||||
|
@ -117,10 +112,6 @@ export class DS4Actor extends Actor {
|
|||
this.overrides = foundry.utils.expandObject({ ...foundry.utils.flattenObject(this.overrides), ...overrides });
|
||||
}
|
||||
|
||||
protected getOriginatingItemOfActiveEffect(effect: ActiveEffect): DS4Item | undefined {
|
||||
return this.items.find((item) => item.uuid === effect.data.origin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply transformations to the Actor data after effects have been applied to the base data.
|
||||
* @override
|
||||
|
@ -184,8 +175,6 @@ export class DS4Actor extends Actor {
|
|||
];
|
||||
case "creature":
|
||||
return ["weapon", "armor", "shield", "equipment", "loot", "spell", "specialCreatureAbility"];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue