mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Fixed so that scrolltexts for armor changes work again
This commit is contained in:
parent
e83d3f7d44
commit
9635387779
4 changed files with 28 additions and 14 deletions
|
|
@ -12,6 +12,7 @@
|
|||
* "Anything that uses another data model value as its value": +1 - Effects that increase traits have to be calculated first at Base priority. (EX: Raise evasion by half your agility)
|
||||
*/
|
||||
|
||||
import { getScrollTextData } from '../../helpers/utils.mjs';
|
||||
import { changeTypes } from './_module.mjs';
|
||||
|
||||
export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
||||
|
|
@ -130,4 +131,27 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
async _preUpdate(changed, options, userId) {
|
||||
const allowed = await super._preUpdate(changed, options, userId);
|
||||
if (allowed === false) return false;
|
||||
|
||||
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||
if (autoSettings.resourceScrollTexts && this.parent.actor?.type === 'character') {
|
||||
const newArmorTotal = (changed.system?.changes ?? []).reduce((acc, change) => {
|
||||
if (change.type === 'armor') acc += change.value.current;
|
||||
return acc;
|
||||
}, 0);
|
||||
|
||||
const armorData = getScrollTextData(this.parent.actor, { value: newArmorTotal }, 'armor');
|
||||
options.scrollingTextData = [armorData];
|
||||
}
|
||||
}
|
||||
|
||||
_onUpdate(changed, options, userId) {
|
||||
super._onUpdate(changed, options, userId);
|
||||
|
||||
if (this.parent.actor && options.scrollingTextData)
|
||||
this.parent.actor.queueScrollText(options.scrollingTextData);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,14 +68,12 @@ export default class ArmorChange extends foundry.abstract.DataModel {
|
|||
}
|
||||
}
|
||||
|
||||
static getInitialValue(locked) {
|
||||
static getInitialValue() {
|
||||
return {
|
||||
key: 'Armor',
|
||||
type: CONFIG.DH.GENERAL.activeEffectModes.armor.id,
|
||||
value: {
|
||||
current: 0,
|
||||
max: 0,
|
||||
locked
|
||||
max: 0
|
||||
},
|
||||
phase: 'initial',
|
||||
priority: 20
|
||||
|
|
@ -87,7 +85,7 @@ export default class ArmorChange extends foundry.abstract.DataModel {
|
|||
name: game.i18n.localize('DAGGERHEART.EFFECTS.ChangeTypes.armor.newArmorEffect'),
|
||||
img: 'icons/equipment/chest/breastplate-helmet-metal.webp',
|
||||
system: {
|
||||
changes: [ArmorChange.getInitialValue(true)]
|
||||
changes: [ArmorChange.getInitialValue()]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,14 +220,6 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
|||
|
||||
addLinkedItemsDiff(changed.system?.features, this.features, options);
|
||||
|
||||
const autoSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation);
|
||||
const armorChanged =
|
||||
changed.system?.marks?.value !== undefined && changed.system.marks.value !== this.marks.value;
|
||||
if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') {
|
||||
const armorData = getScrollTextData(this.parent.parent, changed.system.marks, 'armor');
|
||||
options.scrollingTextData = [armorData];
|
||||
}
|
||||
|
||||
if (changed.system?.actions) {
|
||||
const triggersToRemove = Object.keys(changed.system.actions).reduce((acc, key) => {
|
||||
const action = changed.system.actions[key];
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
</h3>
|
||||
<h3>
|
||||
{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}:
|
||||
{{source.system.baseScore}}
|
||||
{{source.system.armorData.max}}
|
||||
<span>-</span>
|
||||
{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}:
|
||||
{{source.system.baseThresholds.major}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue