[Fix] Itemlink Redux Revengeance (#399)

* Small random fixes

* Added use of ItemLinkFields

* Multiclass levelup fixes

* Fixed our onCreate methods unintentionally being run on all clients

* Remade apps handling

* Added for all class items and subclass

* Restored foreignDocumentUuidField

* Improved

* PR fxies

* Fixed tooltip enrichment

* .

* Reverted silly change
This commit is contained in:
WBHarry 2025-07-26 00:37:30 +02:00 committed by GitHub
parent fcba5041e9
commit 2a4777f1a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 648 additions and 489 deletions

View file

@ -26,15 +26,15 @@ export default class DhpActor extends Actor {
/** @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;

View file

@ -1,4 +1,4 @@
import ActionSelectionDialog from "../applications/dialogs/actionSelectionDialog.mjs";
import ActionSelectionDialog from '../applications/dialogs/actionSelectionDialog.mjs';
/**
* Override and extend the basic Item implementation.

View file

@ -8,19 +8,15 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
const item = await foundry.utils.fromUuid(itemUuid);
if (item) {
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 isEffect = item instanceof ActiveEffect;
await this.enrichText(item, isAction || isEffect);
const type = isAction ? 'action' : item.type;
const type = isAction ? 'action' : isEffect ? 'effect' : item.type;
html = await foundry.applications.handlebars.renderTemplate(
`systems/daggerheart/templates/ui/tooltip/${type}.hbs`,
{
item: item,
description: description,
description: item.system?.enrichedDescription ?? item.enrichedDescription,
config: CONFIG.DH
}
);
@ -126,4 +122,37 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
];
}
}
async enrichText(item, flatStructure) {
const { TextEditor } = foundry.applications.ux;
const enrichPaths = [
{ path: flatStructure ? '' : 'system', name: 'description' },
{ path: 'system', name: 'features' },
{ path: 'system', name: 'actions' },
{ path: 'system', name: 'customActions' }
];
for (let data of enrichPaths) {
const basePath = `${data.path ? `${data.path}.` : ''}${data.name}`;
const pathValue = foundry.utils.getProperty(item, basePath);
if (!pathValue) continue;
if (Array.isArray(pathValue) || pathValue.size) {
for (const [index, itemValue] of pathValue.entries()) {
const itemIsAction = itemValue instanceof game.system.api.models.actions.actionsTypes.base;
const value = itemIsAction || !itemValue?.item ? itemValue : itemValue.item;
const enrichedValue = await TextEditor.enrichHTML(value.description);
if (itemIsAction) value.enrichedDescription = enrichedValue;
else foundry.utils.setProperty(item, `${basePath}.${index}.enrichedDescription`, enrichedValue);
}
} else {
const enrichedValue = await TextEditor.enrichHTML(pathValue);
foundry.utils.setProperty(
item,
`${data.path ? `${data.path}.` : ''}enriched${data.name.capitalize()}`,
enrichedValue
);
}
}
}
}