mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +01:00
Fixed character sheet armor update
This commit is contained in:
parent
aef3d3cd04
commit
81e61a7386
2 changed files with 16 additions and 13 deletions
|
|
@ -629,12 +629,12 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateArmorMarks(event) {
|
async updateArmorMarks(event) {
|
||||||
const armor = this.document.system.armor;
|
const inputValue = Number(event.currentTarget.value);
|
||||||
if (!armor) return;
|
const { value, max } = this.document.system.armorScore;
|
||||||
|
const changeValue = Math.min(inputValue - value, max - value);
|
||||||
|
|
||||||
const maxMarks = this.document.system.armorScore;
|
event.currentTarget.value = inputValue < 0 ? 0 : value + changeValue;
|
||||||
const value = Math.min(Math.max(Number(event.currentTarget.value), 0), maxMarks);
|
this.document.system.updateArmorValue({ value: changeValue });
|
||||||
await armor.update({ 'system.marks.value': value });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
|
|
@ -813,10 +813,13 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
||||||
* Toggles ArmorScore resource value.
|
* Toggles ArmorScore resource value.
|
||||||
* @type {ApplicationClickAction}
|
* @type {ApplicationClickAction}
|
||||||
*/
|
*/
|
||||||
static async #toggleArmor(_, button, element) {
|
static async #toggleArmor(_, button, _element) {
|
||||||
const ArmorValue = Number.parseInt(button.dataset.value);
|
const { value, max } = this.document.system.armorScore;
|
||||||
const newValue = this.document.system.armor.system.marks.value >= ArmorValue ? ArmorValue - 1 : ArmorValue;
|
const inputValue = Number.parseInt(button.dataset.value);
|
||||||
await this.document.system.armor.update({ 'system.marks.value': newValue });
|
const newValue = value >= inputValue ? inputValue - 1 : inputValue;
|
||||||
|
const changeValue = Math.min(newValue - value, max - value);
|
||||||
|
|
||||||
|
this.document.system.updateArmorValue({ value: changeValue });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@
|
||||||
{{#if useResourcePips}}
|
{{#if useResourcePips}}
|
||||||
<div class='slot-value'>
|
<div class='slot-value'>
|
||||||
<div class="slot-bar">
|
<div class="slot-bar">
|
||||||
{{#times document.system.armorScore}}
|
{{#times document.system.armorScore.max}}
|
||||||
<a class='armor-slot' data-action='toggleArmor' data-value="{{add this 1}}">
|
<a class='armor-slot' data-action='toggleArmor' data-value="{{add this 1}}">
|
||||||
{{#if (gte ../document.system.armor.system.marks.value (add this 1))}}
|
{{#if (gte ../document.system.armorScore.value (add this 1))}}
|
||||||
<i class="fa-solid fa-shield"></i>
|
<i class="fa-solid fa-shield"></i>
|
||||||
{{else}}
|
{{else}}
|
||||||
<i class="fa-solid fa-shield-halved"></i>
|
<i class="fa-solid fa-shield-halved"></i>
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="slot-label">
|
<div class="slot-label">
|
||||||
<span class="label">{{localize "DAGGERHEART.GENERAL.armorSlots"}}</span>
|
<span class="label">{{localize "DAGGERHEART.GENERAL.armorSlots"}}</span>
|
||||||
<span class="value">{{document.system.armor.system.marks.value}} / {{document.system.armorScore}}</span>
|
<span class="value">{{document.system.armorScore.value}} / {{document.system.armorScore.max}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue