mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
* FIX: Add enritch to HTMLField FIX: Remove no-HTMLField from Manifest FIX: Convert Scar's HTMLField to StringField FIX: Remove unused HTMLField * REMOVE unused hanldebars helpers * FEAT: add inventory-fieldset-items-V2 and inventory-item-V2 partials for Actors * FIX showLabels to hideTags * FEAT: add template to items sheet * FEAT: add effects tabs on ItemSheet * FEAT: add context menus for all inventory-items * FEAT: add resources to inventory-item template * FEAT: add enritch on inventory-item description FEAT: add extensible behavior on inventory-item-content FEAT: add fade effect on item-img to roll-itmg * FEAT: add eritch to NPC description FIX: missing htmlFieldss on manfiest FIX: add misisng localizations * FIX_ minor fixes * Little resource fix. Noone will notice ._. * FIX: remove default list styles FIX: .extended css reduce max-height, shorten animation duration to 0.5s, and set overflow to auto. FIX: set enriched=notes.enriche on notes.hbs FIX: set experience.value on sidebar.hbs FIX: move tooltip from item-img to img-portrait on inventory-item-V2.hbs REMOVE: unused files --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com> Co-authored-by: WBHarry <williambjrklund@gmail.com>
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import { itemAbleRollParse } from './utils.mjs';
|
|
|
|
export default class RegisterHandlebarsHelpers {
|
|
static registerHelpers() {
|
|
Handlebars.registerHelper({
|
|
add: this.add,
|
|
includes: this.includes,
|
|
times: this.times,
|
|
damageFormula: this.damageFormula,
|
|
damageSymbols: this.damageSymbols,
|
|
rollParsed: this.rollParsed,
|
|
hasProperty: foundry.utils.hasProperty,
|
|
});
|
|
}
|
|
static add(a, b) {
|
|
const aNum = Number.parseInt(a);
|
|
const bNum = Number.parseInt(b);
|
|
return (Number.isNaN(aNum) ? 0 : aNum) + (Number.isNaN(bNum) ? 0 : bNum);
|
|
}
|
|
|
|
static includes(list, item) {
|
|
return list.includes(item);
|
|
}
|
|
|
|
static times(nr, block) {
|
|
var accum = '';
|
|
for (var i = 0; i < nr; ++i) accum += block.fn(i);
|
|
return accum;
|
|
}
|
|
|
|
static damageFormula(attack, actor) {
|
|
const traitTotal = actor.system.traits?.[attack.roll.trait]?.value;
|
|
const instances = [
|
|
attack.damage.parts.map(x => Roll.replaceFormulaData(x.value.getFormula(), actor)).join(' + '),
|
|
traitTotal
|
|
].filter(x => x);
|
|
|
|
return instances.join(traitTotal > 0 ? ' + ' : ' - ');
|
|
}
|
|
|
|
static damageSymbols(damageParts) {
|
|
const symbols = [...new Set(damageParts.reduce((a, c) => a.concat([...c.type]), []))].map(
|
|
p => CONFIG.DH.GENERAL.damageTypes[p].icon
|
|
);
|
|
return new Handlebars.SafeString(Array.from(symbols).map(symbol => `<i class="fa-solid ${symbol}"></i>`));
|
|
}
|
|
|
|
static rollParsed(value, actor, item, numerical) {
|
|
const isNumerical = typeof numerical === 'boolean' ? numerical : false;
|
|
const result = itemAbleRollParse(value, actor, item);
|
|
return isNumerical && !result ? 0 : result;
|
|
}
|
|
}
|