mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 12:54:16 +02:00
* Preload ancestry and community features in description * Corrected comments --------- Co-authored-by: WBHarry <williambjrklund@gmail.com>
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
import { fromUuids, getFeaturesHTMLData } from '../../helpers/utils.mjs';
|
|
import ForeignDocumentUUIDArrayField from '../fields/foreignDocumentUUIDArrayField.mjs';
|
|
import BaseDataItem from './base.mjs';
|
|
|
|
export default class DHCommunity extends BaseDataItem {
|
|
/** @inheritDoc */
|
|
static get metadata() {
|
|
return foundry.utils.mergeObject(super.metadata, {
|
|
label: 'TYPES.Item.community',
|
|
type: 'community',
|
|
hasDescription: true
|
|
});
|
|
}
|
|
|
|
/** @inheritDoc */
|
|
static defineSchema() {
|
|
return {
|
|
...super.defineSchema(),
|
|
features: new ForeignDocumentUUIDArrayField({ type: 'Item' })
|
|
};
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/**@override */
|
|
static DEFAULT_ICON = 'systems/daggerheart/assets/icons/documents/items/village.svg';
|
|
|
|
/**@inheritdoc */
|
|
async getDescriptionData() {
|
|
// Preload all community features for acquisition from the cache
|
|
// todo: make feature acquisition async and replace feature helpers for methods
|
|
await fromUuids(this._source.features);
|
|
|
|
const baseDescription = this.description;
|
|
const features = await getFeaturesHTMLData(this.features);
|
|
|
|
if (!features.length) return { prefix: null, value: baseDescription, suffix: null };
|
|
const suffix = await foundry.applications.handlebars.renderTemplate(
|
|
'systems/daggerheart/templates/sheets/items/description.hbs',
|
|
{ label: 'DAGGERHEART.ITEMS.Community.featuresLabel', features }
|
|
);
|
|
|
|
return { prefix: null, value: baseDescription, suffix };
|
|
}
|
|
}
|