diff --git a/lang/en.json b/lang/en.json index d03ce369..fd278e89 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2259,11 +2259,6 @@ "abilityCheckTitle": "{ability} Check" }, "featureTitle": "Class Feature", - "foundationCard": { - "ancestryTitle": "Ancestry Card", - "communityTitle": "Community Card", - "subclassFeatureTitle": "Subclass Feature" - }, "healingRoll": { "title": "Heal - {damage}", "heal": "Heal", diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index f8d2697f..7f646460 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -51,9 +51,8 @@ import { ItemBrowser } from '../../ui/itemBrowser.mjs'; */ /** - * @template {Constructor} BaseDocumentSheet - * @param {BaseDocumentSheet} Base - The base class to extend. - * @returns {BaseDocumentSheet} + * @template {new (...args: any[]) => {}} T + * @arg Base {T} */ export default function DHApplicationMixin(Base) { class DHSheetV2 extends HandlebarsApplicationMixin(Base) { @@ -123,12 +122,13 @@ export default function DHApplicationMixin(Base) { super._attachPartListeners(partId, htmlElement, options); this._dragDrop.forEach(d => d.bind(htmlElement)); } + /**@inheritdoc */ async _onFirstRender(context, options) { await super._onFirstRender(context, options); const docs = []; - for (var docData of this.relatedDocs) { + for (const docData of this.relatedDocs) { const doc = await foundry.utils.fromUuid(docData.uuid); docs.push(doc); } @@ -247,6 +247,9 @@ export default function DHApplicationMixin(Base) { /* Context Menu */ /* -------------------------------------------- */ + /** + * Create all configured context menus for this application ins tance. + */ _createContextMenus() { for (const config of this.options.contextMenus) { const { handler, selector, options } = config; @@ -257,9 +260,9 @@ export default function DHApplicationMixin(Base) { /* -------------------------------------------- */ /** - * Get the set of ContextMenu options for DomainCards. + * Get the set of ContextMenu options for ActiveEffects. * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance - * @this {CharacterSheet} + * @this {DHSheetV2} * @protected */ static #getEffectContextOptions() { @@ -305,8 +308,13 @@ export default function DHApplicationMixin(Base) { } /** - * Get the set of ContextMenu options. - * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance + * Get the common ContextMenu options for an element. + * @param {Object} options + * @param {boolean} [options.usable=false] - Whether to include an option to use the item or apply damage. + * @param {boolean} [options.toChat=false] - Whether to include an option to send the item to chat. + * @param {boolean} [options.deletable=true] - Whether to include an option to delete the item. + * + * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} */ _getContextMenuCommonOptions({ usable = false, toChat = false, deletable = true }) { const options = [ diff --git a/module/applications/sheets/api/base-actor.mjs b/module/applications/sheets/api/base-actor.mjs index b664929c..67cec44f 100644 --- a/module/applications/sheets/api/base-actor.mjs +++ b/module/applications/sheets/api/base-actor.mjs @@ -7,8 +7,6 @@ const { ActorSheetV2 } = foundry.applications.sheets; /** * A base actor sheet extending {@link ActorSheetV2} via {@link DHApplicationMixin} - * @extends ActorSheetV2 - * @mixes DHSheetV2 */ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { /** @inheritDoc */ @@ -106,7 +104,7 @@ export default class DHBaseActorSheet extends DHApplicationMixin(ActorSheetV2) { /** * Get the set of ContextMenu options for Features. * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance - * @this {DHSheetV2} + * @this {DHBaseActorSheet} * @protected */ static #getFeatureContextOptions() { diff --git a/module/applications/sheets/api/base-item.mjs b/module/applications/sheets/api/base-item.mjs index b5573a0c..6bd91ae8 100644 --- a/module/applications/sheets/api/base-item.mjs +++ b/module/applications/sheets/api/base-item.mjs @@ -7,8 +7,6 @@ const { ItemSheetV2 } = foundry.applications.sheets; /** * A base item sheet extending {@link ItemSheetV2} via {@link DHApplicationMixin} - * @extends ItemSheetV2 - * @mixes DHSheetV2 */ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { /** @inheritDoc */ @@ -108,7 +106,7 @@ export default class DHBaseItemSheet extends DHApplicationMixin(ItemSheetV2) { /** * Get the set of ContextMenu options for Features. * @returns {import('@client/applications/ux/context-menu.mjs').ContextMenuEntry[]} - The Array of context options passed to the ContextMenu instance - * @this {DHSheetV2} + * @this {DHBaseItemSheet} * @protected */ static #getFeatureContextOptions() { diff --git a/module/data/chat-message/abilityUse.mjs b/module/data/chat-message/abilityUse.mjs index c431f14a..07209fe2 100644 --- a/module/data/chat-message/abilityUse.mjs +++ b/module/data/chat-message/abilityUse.mjs @@ -3,7 +3,6 @@ export default class DHAbilityUse extends foundry.abstract.TypeDataModel { const fields = foundry.data.fields; return { - title: new fields.StringField({}), origin: new fields.StringField({}), img: new fields.StringField({}), name: new fields.StringField({}), diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index 3aced0bf..bf535b78 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -124,15 +124,20 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect { return tags; } + /** + * Create a new ChatMessage to display this document’s data. + * @param {String} origin - uuid of a document. TODO: This needs to be reviewed. + */ async toChat(origin) { + /**@type {foundry.documents.ChatMessage} */ const cls = getDocumentClass('ChatMessage'); - const actor = game.actors.get(cls.getSpeaker().actor); + const speaker = cls.getSpeaker(); + const actor = cls.getSpeakerActor(speaker); const systemData = { action: { img: this.img, name: this.name }, - actor: { name: actor.name, img: actor.img }, - author: this.author, - speaker: cls.getSpeaker(), - origin: origin, + actor: { name: actor?.name, img: actor?.img }, + speaker, + origin, description: this.description, actions: [] }; diff --git a/module/documents/item.mjs b/module/documents/item.mjs index a261677a..fb558e8c 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -142,19 +142,16 @@ export default class DHItem extends foundry.documents.Item { } } + /** + * Create a new ChatMessage to display this document’s data + * @param {String} origin - uuid of a document. TODO: This needs to be reviewed. + */ async toChat(origin) { + /**@type {foundry.documents.ChatMessage} */ const cls = getDocumentClass('ChatMessage'); const item = await foundry.utils.fromUuid(origin); const systemData = { - title: - this.type === 'ancestry' - ? game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.ancestryTitle') - : this.type === 'community' - ? game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.communityTitle') - : this.type === 'feature' - ? game.i18n.localize('TYPES.Item.feature') - : game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.subclassFeatureTitle'), origin: origin, img: this.img, item: { @@ -170,7 +167,6 @@ export default class DHItem extends foundry.documents.Item { type: 'abilityUse', user: game.user.id, actor: item.parent, - author: this.author, speaker: cls.getSpeaker(), system: systemData, title: game.i18n.localize('DAGGERHEART.ACTIONS.Config.displayInChat'),