forked from GitHub-Mirrors/foundry-sw5e

Things unfinished: - Migration - The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more - The French - The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points - I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking - I only did a little testing - There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented Things changed from base 5e: - Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message Extra Comments: - Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers - Weapon proficiencies probably need revising - Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e - SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented - SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented - Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
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 owner.createEmbeddedDocuments("ActiveEffect", [{
|
|
label: "New Effect",
|
|
icon: "icons/svg/aura.svg",
|
|
origin: owner.uuid,
|
|
"duration.rounds": li.dataset.effectType === "temporary" ? 1 : undefined,
|
|
disabled: li.dataset.effectType === "inactive"
|
|
}]);
|
|
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: "SW5E.EffectsCategoryTemporary",
|
|
effects: []
|
|
},
|
|
passive: {
|
|
type: "passive",
|
|
label: "SW5E.EffectsCategoryPassive",
|
|
effects: []
|
|
},
|
|
inactive: {
|
|
type: "inactive",
|
|
label: "SW5E.EffectsCategoryInactive",
|
|
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;
|
|
} |