Fixed Weapon/Armor features. Fixed Feature actions

This commit is contained in:
WBHarry 2025-07-23 00:37:25 +02:00
parent 5243260b4d
commit 920ab3fd76
10 changed files with 84 additions and 63 deletions

View file

@ -12,15 +12,15 @@ export default class DHItem extends foundry.documents.Item {
/** @inheritDoc */
getEmbeddedDocument(embeddedName, id, options) {
let doc;
switch ( embeddedName ) {
case "Action":
switch (embeddedName) {
case 'Action':
doc = this.system.actions?.get(id);
if(!doc && this.system.attack?.id === id) doc = this.system.attack;
if (!doc && this.system.attack?.id === id) doc = this.system.attack;
break;
default:
return super.getEmbeddedDocument(embeddedName, id, options);
}
if ( options?.strict && !doc ) {
if (options?.strict && !doc) {
throw new Error(`The key ${id} does not exist in the ${embeddedName} Collection`);
}
return doc;
@ -124,9 +124,9 @@ export default class DHItem extends foundry.documents.Item {
async use(event) {
const actions = this.system.actionsList;
if (actions?.length) {
let action = actions[0];
if (actions.length > 1 && !event?.shiftKey) {
if (actions?.size) {
let action = actions.contents[0];
if (actions.size > 1 && !event?.shiftKey) {
// Actions Choice Dialog
action = await this.selectActionDialog(event);
}

View file

@ -4,19 +4,18 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
let html = options.html;
if (element.dataset.tooltip?.startsWith('#item#')) {
const splitValues = element.dataset.tooltip.slice(6).split('#action#');
const itemUuid = splitValues[0];
const actionId = splitValues.length > 1 ? splitValues[1] : null;
const baseItem = await foundry.utils.fromUuid(itemUuid);
const item = actionId ? baseItem.system.actions.get(actionId) : baseItem;
const itemUuid = element.dataset.tooltip.slice(6);
const item = await foundry.utils.fromUuid(itemUuid);
if (item) {
const type = actionId ? 'action' : item.type;
const description = await TextEditor.enrichHTML(item.system.description);
for (let feature of item.system.features) {
feature.system.enrichedDescription = await TextEditor.enrichHTML(feature.system.description);
const isAction = item instanceof game.system.api.models.actions.actionsTypes.base;
const description = await TextEditor.enrichHTML(isAction ? item.description : item.system.description);
if (item.system?.features) {
for (let feature of item.system.features) {
feature.system.enrichedDescription = await TextEditor.enrichHTML(feature.system.description);
}
}
const type = isAction ? 'action' : item.type;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{