mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
ItemFeatures are now prepended to the description
This commit is contained in:
parent
0b343c9f52
commit
9d353fe54a
9 changed files with 97 additions and 16 deletions
|
|
@ -54,6 +54,22 @@ export default class DHArmor extends AttachableItem {
|
|||
);
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData(large) {
|
||||
const baseDescription = await super.getDescriptionData();
|
||||
const allFeatures = CONFIG.DH.ITEM.allArmorFeatures();
|
||||
const features = this.armorFeatures.map(x => allFeatures[x.value]);
|
||||
if (!features.length) return baseDescription;
|
||||
|
||||
const prepend = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/sheets/items/armor/description.hbs',
|
||||
{ features, large }
|
||||
);
|
||||
|
||||
const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
|
||||
return `${prepend}${mainDescription}`;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preUpdate(changes, options, user) {
|
||||
const allowed = await super._preUpdate(changes, options, user);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* @property {boolean} isInventoryItem- Indicates whether items of this type is a Inventory Item
|
||||
*/
|
||||
|
||||
import { addLinkedItemsDiff, createScrollText, getScrollTextData, updateLinkedItemApps } from '../../helpers/utils.mjs';
|
||||
import { addLinkedItemsDiff, getScrollTextData, updateLinkedItemApps } from '../../helpers/utils.mjs';
|
||||
import { ActionsField } from '../fields/actionField.mjs';
|
||||
import FormulaField from '../fields/formulaField.mjs';
|
||||
|
||||
|
|
@ -124,6 +124,23 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
return [source, page ? `pg ${page}.` : null].filter(x => x).join('. ');
|
||||
}
|
||||
|
||||
/** */
|
||||
async getDescriptionData() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/** */
|
||||
async getEnrichedDescription(large) {
|
||||
if (!this.metadata.hasDescription) return '';
|
||||
|
||||
const description = await this.getDescriptionData(large);
|
||||
return await foundry.applications.ux.TextEditor.implementation.enrichHTML(description, {
|
||||
relativeTo: this,
|
||||
rollData: this.getRollData(),
|
||||
secrets: this.isOwner
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
|
||||
* @param {object} [options] - Options which modify the getRollData method.
|
||||
|
|
|
|||
|
|
@ -110,6 +110,22 @@ export default class DHWeapon extends AttachableItem {
|
|||
);
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData(large) {
|
||||
const baseDescription = await super.getDescriptionData();
|
||||
const allFeatures = CONFIG.DH.ITEM.allWeaponFeatures();
|
||||
const features = this.weaponFeatures.map(x => allFeatures[x.value]);
|
||||
if (!features.length) return baseDescription;
|
||||
|
||||
const prepend = await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/sheets/items/weapon/description.hbs',
|
||||
{ features, large }
|
||||
);
|
||||
|
||||
const mainDescription = baseDescription ? `\n<hr>\n${baseDescription}` : '';
|
||||
return `${prepend}${mainDescription}`;
|
||||
}
|
||||
|
||||
prepareDerivedData() {
|
||||
this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue