Merged with main

This commit is contained in:
WBHarry 2025-08-10 01:31:05 +02:00
commit 130b2bf100
65 changed files with 1085 additions and 860 deletions

View file

@ -631,13 +631,33 @@ export default class CharacterSheet extends DHBaseActorSheet {
},
hasRoll: true
};
this.document.diceRoll({
const result = await this.document.diceRoll({
...config,
headerTitle: `${game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll')}: ${this.actor.name}`,
title: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
ability: abilityLabel
})
});
setTimeout(() => {
this.consumeResource(result?.costs);
}, 50);
}
async consumeResource(costs) {
if (!costs?.length) return;
const usefulResources = foundry.utils.deepClone(this.actor.system.resources);
const resources = game.system.api.fields.ActionFields.CostField.getRealCosts(costs).map(c => {
const resource = usefulResources[c.key];
return {
key: c.key,
value: (c.total ?? c.value) * (resource.isReversed ? 1 : -1),
target: resource.target,
keyIsID: resource.keyIsID
};
});
await this.actor.modifyResource(resources);
}
//TODO: redo toggleEquipItem method

View file

@ -101,8 +101,7 @@ export default class DhpEnvironment extends DHBaseActorSheet {
const item = event.currentTarget.closest('.inventory-item');
if (item) {
const adversary = game.actors.find(x => x.type === 'adversary' && x.id === item.dataset.itemId);
const adversaryData = { type: 'Actor', uuid: adversary.uuid };
const adversaryData = { type: 'Actor', uuid: item.dataset.itemUuid };
event.dataTransfer.setData('text/plain', JSON.stringify(adversaryData));
event.dataTransfer.setDragImage(item, 60, 0);
}

View file

@ -51,9 +51,8 @@ import { ItemBrowser } from '../../ui/itemBrowser.mjs';
*/
/**
* @template {Constructor<foundry.applications.api.DocumentSheet>} 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 = [
@ -325,7 +333,7 @@ export default function DHApplicationMixin(Base) {
}
];
if (usable)
if (usable) {
options.unshift({
name: 'DAGGERHEART.GENERAL.damage',
icon: 'fa-solid fa-explosion',
@ -340,15 +348,16 @@ export default function DHApplicationMixin(Base) {
}
});
options.unshift({
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
icon: 'fa-solid fa-burst',
condition: target => {
const doc = getDocFromElementSync(target);
return doc && !(doc.type === 'domainCard' && doc.system.inVault);
},
callback: async (target, event) => (await getDocFromElement(target)).use(event)
});
options.unshift({
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
icon: 'fa-solid fa-burst',
condition: target => {
const doc = getDocFromElementSync(target);
return doc && !(doc.type === 'domainCard' && doc.system.inVault);
},
callback: async (target, event) => (await getDocFromElement(target)).use(event)
});
}
if (toChat)
options.push({

View file

@ -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() {

View file

@ -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() {