Working armor application

This commit is contained in:
WBHarry 2026-02-09 18:23:30 +01:00
parent 7036a53c71
commit 514e0260eb
9 changed files with 99 additions and 18 deletions

View file

@ -34,6 +34,13 @@ export default class ArmorSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
...super.PARTS
};
_attachPartListeners(partId, htmlElement, options) {
super._attachPartListeners(partId, htmlElement, options);
for (const element of htmlElement.querySelectorAll('.base-score-input'))
element.addEventListener('change', this.updateArmorEffect.bind(this));
}
/**@inheritdoc */
async _preparePartContext(partId, context) {
await super._preparePartContext(partId, context);
@ -41,12 +48,22 @@ export default class ArmorSheet extends ItemAttachmentSheet(DHBaseItemSheet) {
switch (partId) {
case 'settings':
context.features = this.document.system.armorFeatures.map(x => x.value);
context.armorScore = this.document.system.armorEffect?.system.armorData?.max;
break;
}
return context;
}
async updateArmorEffect(event) {
const value = Number.parseInt(event.target.value);
const armorEffect = this.document.system.armorEffect;
if (Number.isNaN(value) || !armorEffect) return;
await armorEffect.system.updateArmorMax(value);
this.render();
}
/**
* Callback function used by `tagifyElement`.
* @param {Array<Object>} selectedOptions - The currently selected tag objects.