boilerplate
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
export const TOTEM = {};
|
||||
|
||||
/**
|
||||
* The set of Ability Scores used within the sytem.
|
||||
* @type {Object}
|
||||
*/
|
||||
TOTEM.abilities = {
|
||||
"str": "TOTEM.AbilityStr",
|
||||
"dex": "TOTEM.AbilityDex",
|
||||
"con": "TOTEM.AbilityCon",
|
||||
"int": "TOTEM.AbilityInt",
|
||||
"wis": "TOTEM.AbilityWis",
|
||||
"cha": "TOTEM.AbilityCha"
|
||||
};
|
||||
|
||||
TOTEM.abilityAbbreviations = {
|
||||
"str": "TOTEM.AbilityStrAbbr",
|
||||
"dex": "TOTEM.AbilityDexAbbr",
|
||||
"con": "TOTEM.AbilityConAbbr",
|
||||
"int": "TOTEM.AbilityIntAbbr",
|
||||
"wis": "TOTEM.AbilityWisAbbr",
|
||||
"cha": "TOTEM.AbilityChaAbbr"
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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 document 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.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.disabled ) categories.inactive.effects.push(e);
|
||||
else if ( e.isTemporary ) categories.temporary.effects.push(e);
|
||||
else categories.passive.effects.push(e);
|
||||
}
|
||||
return categories;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Define a set of template paths to pre-load
|
||||
* Pre-loaded templates are compiled and cached for fast access when rendering
|
||||
* @return {Promise}
|
||||
*/
|
||||
export const preloadHandlebarsTemplates = async function() {
|
||||
return loadTemplates([
|
||||
|
||||
// Actor partials.
|
||||
"systems/totem/templates/actor/parts/actor-features.html",
|
||||
"systems/totem/templates/actor/parts/actor-items.html",
|
||||
"systems/totem/templates/actor/parts/actor-spells.html",
|
||||
"systems/totem/templates/actor/parts/actor-effects.html",
|
||||
]);
|
||||
};
|
||||
Reference in New Issue
Block a user