This commit is contained in:
WBHarry 2026-03-15 22:35:16 +01:00
parent 4332a1ba7a
commit 7a8591bb1b
5 changed files with 17 additions and 17 deletions

View file

@ -10,8 +10,8 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
this.reject = reject; this.reject = reject;
this.actor = actor; this.actor = actor;
this.damage = damage; this.damage = damage;
// this.damageType = damageType;
this.damageType = ['physical']; this.damageType = damageType;
this.rulesDefault = game.settings.get( this.rulesDefault = game.settings.get(
CONFIG.DH.id, CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Automation CONFIG.DH.SETTINGS.gameSettings.Automation
@ -340,9 +340,8 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
const { selectedStressMarks, stressReductions, currentDamage } = this.getDamageInfo(); const { selectedStressMarks, stressReductions, currentDamage } = this.getDamageInfo();
const armorChanges = this.marks.armor.reduce((acc, source) => { const armorChanges = this.marks.armor.reduce((acc, source) => {
const amount = Object.values(source.marks).filter(x => x.selected).length; const amount = Object.values(source.marks).filter(x => x.selected).length;
if (!amount) return acc; if (amount) acc.push({ uuid: source.effect.uuid, amount });
acc.push({ uuid: source.effect.uuid, amount });
return acc; return acc;
}, []); }, []);
const stressSpent = const stressSpent =

View file

@ -190,11 +190,14 @@ export default class Party extends DHBaseActorSheet {
* Toggles a armor slot resource value. * Toggles a armor slot resource value.
* @type {ApplicationClickAction} * @type {ApplicationClickAction}
*/ */
static async #toggleArmorSlot(_, target, element) { static async #toggleArmorSlot(_, target) {
const armorItem = await foundry.utils.fromUuid(target.dataset.itemUuid); const actor = game.actors.get(target.dataset.actorId);
const armorValue = Number.parseInt(target.dataset.value); const { value, max } = actor.system.armorScore;
const newValue = armorItem.system.marks.value >= armorValue ? armorValue - 1 : armorValue; const inputValue = Number.parseInt(target.dataset.value);
await armorItem.update({ 'system.marks.value': newValue }); const newValue = value >= inputValue ? inputValue - 1 : inputValue;
const changeValue = Math.min(newValue - value, max - value);
await actor.system.updateArmorValue({ value: changeValue });
this.render(); this.render();
} }

View file

@ -527,7 +527,7 @@ export default class DhCharacter extends DhCreature {
const updateValues = Object.values(embeddedUpdates); const updateValues = Object.values(embeddedUpdates);
for (const [index, { doc, updates }] of updateValues.entries()) for (const [index, { doc, updates }] of updateValues.entries())
doc.updateEmbeddedDocuments('ActiveEffect', updates, { render: index === updateValues.length - 1 }); await doc.updateEmbeddedDocuments('ActiveEffect', updates, { render: index === updateValues.length - 1 });
} }
async updateArmorEffectValue({ uuid, value }) { async updateArmorEffectValue({ uuid, value }) {

View file

@ -52,13 +52,12 @@
</div> </div>
</div> </div>
{{#if actor.system.armor.system.marks}} {{#if actor.system.armorScore.max}}
<div class="slot-section"> <div class="slot-section">
<div class="slot-bar"> <div class="slot-bar">
{{#times actor.system.armorScore}} {{#times actor.system.armorScore.max}}
<a class='armor-slot' <a class='armor-slot' data-action='toggleArmorSlot' data-actor-id="{{actor.id}}" data-value="{{add this 1}}">
data-action='toggleArmorSlot' data-actor-id="{{actor.uuid}}" data-item-uuid="{{actor.system.armor.uuid}}" data-value="{{add this 1}}"> {{#if (gte actor.system.armorScore.value (add this 1))}}
{{#if (gte actor.system.armor.system.marks.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>
@ -68,7 +67,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">{{actor.system.armor.system.marks.value}} / {{actor.system.armorScore}}</span> <span class="value">{{actor.system.armorScore.value}} / {{actor.system.armorScore.max}}</span>
</div> </div>
</div> </div>
{{/if}} {{/if}}

View file

@ -18,6 +18,5 @@
collection=effects.inactives collection=effects.inactives
canCreate=true canCreate=true
hideResources=true hideResources=true
disabled=true
}} }}
</section> </section>