mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Working armor application
This commit is contained in:
parent
7036a53c71
commit
514e0260eb
9 changed files with 99 additions and 18 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue