forked from GitHub-Mirrors/foundry-sw5e

System main update to be inline with dnd5e 1.1.1 Added active effects to as many sheets as I thought applicable. Please check loot, I made an attempt but it may be broken All .less .css and actor .html updates were made to the old actors. New actors may be broken with this update removed templates\actors\oldActor\parts\actor-effects.html for newer templates\actors\parts\active-effects.html removed module\apps\cast-dialog, templates\apps\cast-cast.html, and templates\items\cast.html. I do not think they are used, I think they were deprecated when powers were treated as items, if not we can add them back in. **NOTE** REQUIRES Foundry 0.7.6
63 lines
No EOL
2.1 KiB
JavaScript
63 lines
No EOL
2.1 KiB
JavaScript
/**
|
|
* Manage Active Effect instances through the Actor Sheet via effect control buttons.
|
|
* @param {MouseEvent} event The left-click event on the effect control
|
|
* @param {Actor|Item} owner The owning entity which manages this effect
|
|
*/
|
|
export function onManageActiveEffect(event, owner) {
|
|
event.preventDefault();
|
|
const a = event.currentTarget;
|
|
const li = a.closest("li");
|
|
const effect = li.dataset.effectId ? owner.effects.get(li.dataset.effectId) : null;
|
|
switch ( a.dataset.action ) {
|
|
case "create":
|
|
return ActiveEffect.create({
|
|
label: "New Effect",
|
|
icon: "icons/svg/aura.svg",
|
|
origin: owner.uuid,
|
|
"duration.rounds": li.dataset.effectType === "temporary" ? 1 : undefined,
|
|
disabled: li.dataset.effectType === "inactive"
|
|
}, owner).create();
|
|
case "edit":
|
|
return effect.sheet.render(true);
|
|
case "delete":
|
|
return effect.delete();
|
|
case "toggle":
|
|
return effect.update({disabled: !effect.data.disabled});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Prepare the data structure for Active Effects which are currently applied to an Actor or Item.
|
|
* @param {ActiveEffect[]} effects The array of Active Effect instances to prepare sheet data for
|
|
* @return {object} Data for rendering
|
|
*/
|
|
export function prepareActiveEffectCategories(effects) {
|
|
|
|
// Define effect header categories
|
|
const categories = {
|
|
temporary: {
|
|
type: "temporary",
|
|
label: "Temporary Effects",
|
|
effects: []
|
|
},
|
|
passive: {
|
|
type: "passive",
|
|
label: "Passive Effects",
|
|
effects: []
|
|
},
|
|
inactive: {
|
|
type: "inactive",
|
|
label: "Inactive Effects",
|
|
effects: []
|
|
}
|
|
};
|
|
|
|
// Iterate over active effects, classifying them into categories
|
|
for ( let e of effects ) {
|
|
e._getSourceName(); // Trigger a lookup for the source name
|
|
if ( e.data.disabled ) categories.inactive.effects.push(e);
|
|
else if ( e.isTemporary ) categories.temporary.effects.push(e);
|
|
else categories.passive.effects.push(e);
|
|
}
|
|
return categories;
|
|
} |