mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed stress resources management for DamageReduction
This commit is contained in:
parent
5dafdaafcd
commit
3953a6fbe9
2 changed files with 21 additions and 2 deletions
|
|
@ -1101,6 +1101,7 @@
|
|||
"Notifications": {
|
||||
"DamageAlreadyNone": "The damage has already been reduced to none",
|
||||
"NoAvailableArmorMarks": "You have no more available armor marks",
|
||||
"NotEnoughStress": "You don't have enough stress",
|
||||
"DamageIgnore": "{character} did not take damage"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
|
||||
/** @inheritDoc */
|
||||
get title() {
|
||||
return `Damage Options`;
|
||||
return game.i18n.localize('DAGGERHEART.DamageReduction.Title');
|
||||
}
|
||||
|
||||
async _prepareContext(_options) {
|
||||
|
|
@ -167,12 +167,30 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
static useStressReduction(_, target) {
|
||||
const damageValue = Number(target.dataset.reduction);
|
||||
const stressReduction = this.availableStressReductions[damageValue];
|
||||
const { currentDamage } = this.getDamageInfo();
|
||||
const { currentDamage, selectedStressMarks, stressReductions } = this.getDamageInfo();
|
||||
|
||||
if (stressReduction.selected) {
|
||||
stressReduction.selected = false;
|
||||
|
||||
const currentDamageLabel = getDamageLabel(currentDamage);
|
||||
for (let reduction of stressReductions) {
|
||||
if (reduction.selected && reduction.to === currentDamageLabel) {
|
||||
reduction.selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.render();
|
||||
} else {
|
||||
const stressReductionStress = this.availableStressReductions
|
||||
? stressReductions.reduce((acc, red) => acc + red.cost, 0)
|
||||
: 0;
|
||||
const currentStress =
|
||||
this.actor.system.resources.stress.value + selectedStressMarks.length + stressReductionStress;
|
||||
if (currentStress + stressReduction.cost > this.actor.system.resources.stress.maxTotal) {
|
||||
ui.notifications.info(game.i18n.localize('DAGGERHEART.DamageReduction.Notifications.NotEnoughStress'));
|
||||
return;
|
||||
}
|
||||
|
||||
const reducedDamage = currentDamage !== this.damage ? getDamageLabel(currentDamage) : null;
|
||||
const currentDamageLabel = reducedDamage ?? getDamageLabel(this.damage);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue