mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
[V14] Armor System ArmorScore (#1744)
* Readded so that armor items have their system defined armor instead of using an ActiveEffect * Consolidate armor source retrieval * Fix regression with updating armor when sources are disabled * Simplify armor pip update * Use helper in damage reduction dialog * . * Corrected SRD Armor Items --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com>
This commit is contained in:
parent
50dcbf4396
commit
33fb7bcc69
45 changed files with 365 additions and 1535 deletions
|
|
@ -19,6 +19,14 @@ export default class DHArmor extends AttachableItem {
|
|||
...super.defineSchema(),
|
||||
tier: new fields.NumberField({ required: true, integer: true, initial: 1, min: 1 }),
|
||||
equipped: new fields.BooleanField({ initial: false }),
|
||||
armor: new fields.SchemaField({
|
||||
current: new fields.NumberField({ integer: true, min: 0, initial: 0 }),
|
||||
max: new fields.NumberField({ required: true, integer: true, initial: 0 })
|
||||
}),
|
||||
baseThresholds: new fields.SchemaField({
|
||||
major: new fields.NumberField({ integer: true, initial: 0 }),
|
||||
severe: new fields.NumberField({ integer: true, initial: 0 })
|
||||
}),
|
||||
armorFeatures: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
value: new fields.StringField({
|
||||
|
|
@ -27,11 +35,7 @@ export default class DHArmor extends AttachableItem {
|
|||
effectIds: new fields.ArrayField(new fields.StringField({ required: true })),
|
||||
actionIds: new fields.ArrayField(new fields.StringField({ required: true }))
|
||||
})
|
||||
),
|
||||
baseThresholds: new fields.SchemaField({
|
||||
major: new fields.NumberField({ integer: true, initial: 0 }),
|
||||
severe: new fields.NumberField({ integer: true, initial: 0 })
|
||||
})
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -48,17 +52,6 @@ export default class DHArmor extends AttachableItem {
|
|||
);
|
||||
}
|
||||
|
||||
get armorEffect() {
|
||||
return this.parent.effects.find(x => x.system.armorData);
|
||||
}
|
||||
|
||||
get armorData() {
|
||||
const armorEffect = this.armorEffect;
|
||||
if (!armorEffect) return { value: 0, max: 0 };
|
||||
|
||||
return armorEffect.system.armorData;
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async getDescriptionData() {
|
||||
const baseDescription = this.description;
|
||||
|
|
@ -73,17 +66,6 @@ export default class DHArmor extends AttachableItem {
|
|||
return { prefix, value: baseDescription, suffix: null };
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _onCreate(_data, _options, userId) {
|
||||
if (userId !== game.user.id) return;
|
||||
|
||||
if (!this.parent.effects.some(x => x.system.armorData)) {
|
||||
this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||
game.system.api.data.activeEffects.changeTypes.armor.getDefaultArmorEffect()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preUpdate(changes, options, user) {
|
||||
const allowed = await super._preUpdate(changes, options, user);
|
||||
|
|
@ -184,7 +166,7 @@ export default class DHArmor extends AttachableItem {
|
|||
*/
|
||||
_getTags() {
|
||||
const tags = [
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.armorData.max}`,
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.armor.max}`,
|
||||
`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseThresholds.base')}: ${this.baseThresholds.major} / ${this.baseThresholds.severe}`
|
||||
];
|
||||
|
||||
|
|
@ -196,7 +178,7 @@ export default class DHArmor extends AttachableItem {
|
|||
* @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects.
|
||||
*/
|
||||
_getLabels() {
|
||||
const labels = [`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.armorData.max}`];
|
||||
const labels = [`${game.i18n.localize('DAGGERHEART.ITEMS.Armor.baseScore')}: ${this.armor.max}`];
|
||||
return labels;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -220,6 +220,19 @@ 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?.armor?.current !== undefined && changed.system.armor.current !== this.armor.current;
|
||||
if (armorChanged && autoSettings.resourceScrollTexts && this.parent.parent?.type === 'character') {
|
||||
const armorChangeValue = changed.system.armor.current - this.armor.current;
|
||||
const armorData = getScrollTextData(
|
||||
this.parent.parent,
|
||||
{ value: armorChangeValue + this.parent.parent.system.armorScore.value },
|
||||
'armor'
|
||||
);
|
||||
options.scrollingTextData = [armorData];
|
||||
}
|
||||
|
||||
if (changed.system?.actions) {
|
||||
const triggersToRemove = Object.keys(changed.system.actions).reduce((acc, key) => {
|
||||
const action = changed.system.actions[key];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue