From 3c33158d11f7c1a0651e1a98beba7469cce59d56 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sat, 14 Jun 2025 19:41:17 +0200 Subject: [PATCH] Fixed so @ strings can be parsed as active effect values --- lang/en.json | 41 +----- module/config/itemConfig.mjs | 157 ++------------------- module/data/item/armor.mjs | 1 + module/data/item/weapon.mjs | 1 + module/documents/activeEffect.mjs | 5 + templates/sheets/items/armor/settings.hbs | 2 + templates/sheets/items/weapon/settings.hbs | 2 + 7 files changed, 26 insertions(+), 183 deletions(-) diff --git a/lang/en.json b/lang/en.json index 7f083984..6fc88758 100755 --- a/lang/en.json +++ b/lang/en.json @@ -264,6 +264,7 @@ } }, "Tiers": { + "singular": "Tier", "tier1": "Tier 1", "tier2": "Tier 2", "tier3": "Tier 3", @@ -620,25 +621,9 @@ } }, "WeaponFeature": { - "Barrier1": { - "Name": "Barrier 1", - "Description": "+1 to Armor Score; -1 to Evasion" - }, - "Barrier2": { - "Name": "Barrier 2", - "Description": "+2 to Armor Score; -1 to Evasion" - }, - "Barrier3": { - "Name": "Barrier 3", - "Description": "+3 to Armor Score; -1 to Evasion" - }, - "Barrier4": { - "Name": "Barrier 4", - "Description": "+4 to Armor Score; -1 to Evasion" - }, - "Barrier5": { - "Name": "Barrier 5", - "Description": "+5 to Armor Score; -1 to Evasion" + "Barrier": { + "Name": "Barrier", + "Description": "+{armorScore} to Armor Score; -1 to Evasion" }, "Bonded": { "Name": "Bonded", @@ -764,21 +749,9 @@ "Name": "Powerful", "Description": "On a successful attack, roll an additional damage die and discard the lowest result." }, - "Protective1": { - "Name": "Protective 1", - "Description": "+1 to Armor Score" - }, - "Protective2": { - "Name": "Protective 2", - "Description": "+2 to Armor Score" - }, - "Protective3": { - "Name": "Protective 3", - "Description": "+3 to Armor Score" - }, - "Protective4": { - "Name": "Protective 4", - "Description": "+4 to Armor Score" + "Protective": { + "Name": "Protective", + "Description": "+{tier} to Armor Score" }, "Quick": { "Name": "Quick", diff --git a/module/config/itemConfig.mjs b/module/config/itemConfig.mjs index 071a08ad..b0cbb9aa 100644 --- a/module/config/itemConfig.mjs +++ b/module/config/itemConfig.mjs @@ -187,112 +187,16 @@ export const armorFeatures = { }; export const weaponFeatures = { - barrier1: { - label: 'DAGGERHEART.WeaponFeature.Barrier1.Name', - description: 'DAGGERHEART.WeaponFeature.Barrier1.Description', + barrier: { + label: 'DAGGERHEART.WeaponFeature.Barrier.Name', + description: 'DAGGERHEART.WeaponFeature.Barrier.Description', effects: [ { changes: [ { key: 'system.bonuses.armorScore', mode: 2, - value: '1' - } - ] - }, - { - changes: [ - { - key: 'system.evasion.bonus', - mode: 2, - value: '-1' - } - ] - } - ] - }, - barrier2: { - label: 'DAGGERHEART.WeaponFeature.Barrier2.Name', - description: 'DAGGERHEART.WeaponFeature.Barrier2.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '2' - } - ] - }, - { - changes: [ - { - key: 'system.evasion.bonus', - mode: 2, - value: '-1' - } - ] - } - ] - }, - barrier3: { - label: 'DAGGERHEART.WeaponFeature.Barrier3.Name', - description: 'DAGGERHEART.WeaponFeature.Barrier3.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '3' - } - ] - }, - { - changes: [ - { - key: 'system.evasion.bonus', - mode: 2, - value: '-1' - } - ] - } - ] - }, - barrier4: { - label: 'DAGGERHEART.WeaponFeature.Barrier4.Name', - description: 'DAGGERHEART.WeaponFeature.Barrier4.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '4' - } - ] - }, - { - changes: [ - { - key: 'system.evasion.bonus', - mode: 2, - value: '-1' - } - ] - } - ] - }, - barrier5: { - label: 'DAGGERHEART.WeaponFeature.Barrier5.Name', - description: 'DAGGERHEART.WeaponFeature.Barrier5.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '5' + value: '@system.tier + 1' } ] }, @@ -520,61 +424,16 @@ export const weaponFeatures = { label: 'DAGGERHEART.WeaponFeature.Powerful.Name', description: 'DAGGERHEART.WeaponFeature.Powerful.Description' }, - protective1: { - label: 'DAGGERHEART.WeaponFeature.Protective1.Name', - description: 'DAGGERHEART.WeaponFeature.Protective1.Description', + protective: { + label: 'DAGGERHEART.WeaponFeature.Protective.Name', + description: 'DAGGERHEART.WeaponFeature.Protective.Description', effects: [ { changes: [ { key: 'system.bonuses.armorScore', mode: 2, - value: '1' - } - ] - } - ] - }, - protective2: { - label: 'DAGGERHEART.WeaponFeature.Protective2.Name', - description: 'DAGGERHEART.WeaponFeature.Protective2.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '2' - } - ] - } - ] - }, - protective3: { - label: 'DAGGERHEART.WeaponFeature.Protective3.Name', - description: 'DAGGERHEART.WeaponFeature.Protective3.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '3' - } - ] - } - ] - }, - protective4: { - label: 'DAGGERHEART.WeaponFeature.Protective4.Name', - description: 'DAGGERHEART.WeaponFeature.Protective4.Description', - effects: [ - { - changes: [ - { - key: 'system.bonuses.armorScore', - mode: 2, - value: '4' + value: '@system.tier' } ] } diff --git a/module/data/item/armor.mjs b/module/data/item/armor.mjs index cae74a02..7a17b8a7 100644 --- a/module/data/item/armor.mjs +++ b/module/data/item/armor.mjs @@ -18,6 +18,7 @@ export default class DHArmor extends BaseDataItem { const fields = foundry.data.fields; return { ...super.defineSchema(), + tier: new fields.NumberField({ required: true, integer: true, initial: 1 }), equipped: new fields.BooleanField({ initial: false }), baseScore: new fields.NumberField({ integer: true, initial: 0 }), features: new fields.ArrayField( diff --git a/module/data/item/weapon.mjs b/module/data/item/weapon.mjs index 016168c0..71279b7a 100644 --- a/module/data/item/weapon.mjs +++ b/module/data/item/weapon.mjs @@ -22,6 +22,7 @@ export default class DHWeapon extends BaseDataItem { const fields = foundry.data.fields; return { ...super.defineSchema(), + tier: new fields.NumberField({ required: true, integer: true, initial: 1 }), equipped: new fields.BooleanField({ initial: false }), //SETTINGS diff --git a/module/documents/activeEffect.mjs b/module/documents/activeEffect.mjs index af60c6b4..7bbf79e3 100644 --- a/module/documents/activeEffect.mjs +++ b/module/documents/activeEffect.mjs @@ -19,4 +19,9 @@ export default class DhActiveEffect extends ActiveEffect { await super._preCreate(data, options, user); } + + static applyField(model, change, field) { + change.value = Roll.safeEval(Roll.replaceFormulaData(change.value, change.effect.parent)); + super.applyField(model, change, field); + } } diff --git a/templates/sheets/items/armor/settings.hbs b/templates/sheets/items/armor/settings.hbs index 56fefc33..5f3d749b 100644 --- a/templates/sheets/items/armor/settings.hbs +++ b/templates/sheets/items/armor/settings.hbs @@ -6,6 +6,8 @@
{{localize tabs.settings.label}} + {{localize "DAGGERHEART.Tiers.singular"}} + {{formField systemFields.tier value=source.system.tier}} {{localize "DAGGERHEART.Sheets.Armor.baseScore"}} {{formField systemFields.baseScore value=source.system.baseScore}} diff --git a/templates/sheets/items/weapon/settings.hbs b/templates/sheets/items/weapon/settings.hbs index b7063d37..aaa5192b 100644 --- a/templates/sheets/items/weapon/settings.hbs +++ b/templates/sheets/items/weapon/settings.hbs @@ -5,6 +5,8 @@ >
{{localize tabs.settings.label}} + {{localize "DAGGERHEART.Tiers.singular"}} + {{formField systemFields.tier value=source.system.tier}} {{localize "DAGGERHEART.Sheets.Weapon.SecondaryWeapon"}} {{formField systemFields.secondary value=source.system.secondary}} {{localize "DAGGERHEART.Sheets.Weapon.Trait"}}