Went over all adversaries to fix missing ranges

This commit is contained in:
WBHarry 2025-08-15 16:13:43 +02:00
parent 006f9dde1f
commit 9aef766c8a
131 changed files with 1187 additions and 1030 deletions

View file

@ -1,3 +1,4 @@
import { getDocFromElement } from '../../../helpers/utils.mjs';
import DHBaseActorSheet from '../api/base-actor.mjs';
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
@ -53,6 +54,15 @@ export default class AdversarySheet extends DHBaseActorSheet {
return context;
}
/**@inheritdoc */
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
htmlElement.querySelectorAll('.inventory-item-resource').forEach(element => {
element.addEventListener('change', this.updateItemResource.bind(this));
});
}
/**
* Prepare render context for the Biography part.
* @param {ApplicationRenderContext} context
@ -121,4 +131,18 @@ export default class AdversarySheet extends DHBaseActorSheet {
this.actor.diceRoll(config);
}
/* -------------------------------------------- */
/* Application Listener Actions */
/* -------------------------------------------- */
async updateItemResource(event) {
const item = await getDocFromElement(event.currentTarget);
if (!item) return;
const max = event.currentTarget.max ? Number(event.currentTarget.max) : null;
const value = max ? Math.min(Number(event.currentTarget.value), max) : event.currentTarget.value;
await item.update({ 'system.resource.value': value });
this.render();
}
}