Fixed so @ strings can be parsed as active effect values

This commit is contained in:
WBHarry 2025-06-14 19:41:17 +02:00
parent b8482da848
commit 3c33158d11
7 changed files with 26 additions and 183 deletions

View file

@ -264,6 +264,7 @@
} }
}, },
"Tiers": { "Tiers": {
"singular": "Tier",
"tier1": "Tier 1", "tier1": "Tier 1",
"tier2": "Tier 2", "tier2": "Tier 2",
"tier3": "Tier 3", "tier3": "Tier 3",
@ -620,25 +621,9 @@
} }
}, },
"WeaponFeature": { "WeaponFeature": {
"Barrier1": { "Barrier": {
"Name": "Barrier 1", "Name": "Barrier",
"Description": "+1 to Armor Score; -1 to Evasion" "Description": "+{armorScore} 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"
}, },
"Bonded": { "Bonded": {
"Name": "Bonded", "Name": "Bonded",
@ -764,21 +749,9 @@
"Name": "Powerful", "Name": "Powerful",
"Description": "On a successful attack, roll an additional damage die and discard the lowest result." "Description": "On a successful attack, roll an additional damage die and discard the lowest result."
}, },
"Protective1": { "Protective": {
"Name": "Protective 1", "Name": "Protective",
"Description": "+1 to Armor Score" "Description": "+{tier} 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"
}, },
"Quick": { "Quick": {
"Name": "Quick", "Name": "Quick",

View file

@ -187,112 +187,16 @@ export const armorFeatures = {
}; };
export const weaponFeatures = { export const weaponFeatures = {
barrier1: { barrier: {
label: 'DAGGERHEART.WeaponFeature.Barrier1.Name', label: 'DAGGERHEART.WeaponFeature.Barrier.Name',
description: 'DAGGERHEART.WeaponFeature.Barrier1.Description', description: 'DAGGERHEART.WeaponFeature.Barrier.Description',
effects: [ effects: [
{ {
changes: [ changes: [
{ {
key: 'system.bonuses.armorScore', key: 'system.bonuses.armorScore',
mode: 2, mode: 2,
value: '1' value: '@system.tier + 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'
} }
] ]
}, },
@ -520,61 +424,16 @@ export const weaponFeatures = {
label: 'DAGGERHEART.WeaponFeature.Powerful.Name', label: 'DAGGERHEART.WeaponFeature.Powerful.Name',
description: 'DAGGERHEART.WeaponFeature.Powerful.Description' description: 'DAGGERHEART.WeaponFeature.Powerful.Description'
}, },
protective1: { protective: {
label: 'DAGGERHEART.WeaponFeature.Protective1.Name', label: 'DAGGERHEART.WeaponFeature.Protective.Name',
description: 'DAGGERHEART.WeaponFeature.Protective1.Description', description: 'DAGGERHEART.WeaponFeature.Protective.Description',
effects: [ effects: [
{ {
changes: [ changes: [
{ {
key: 'system.bonuses.armorScore', key: 'system.bonuses.armorScore',
mode: 2, mode: 2,
value: '1' value: '@system.tier'
}
]
}
]
},
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'
} }
] ]
} }

View file

@ -18,6 +18,7 @@ export default class DHArmor extends BaseDataItem {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
...super.defineSchema(), ...super.defineSchema(),
tier: new fields.NumberField({ required: true, integer: true, initial: 1 }),
equipped: new fields.BooleanField({ initial: false }), equipped: new fields.BooleanField({ initial: false }),
baseScore: new fields.NumberField({ integer: true, initial: 0 }), baseScore: new fields.NumberField({ integer: true, initial: 0 }),
features: new fields.ArrayField( features: new fields.ArrayField(

View file

@ -22,6 +22,7 @@ export default class DHWeapon extends BaseDataItem {
const fields = foundry.data.fields; const fields = foundry.data.fields;
return { return {
...super.defineSchema(), ...super.defineSchema(),
tier: new fields.NumberField({ required: true, integer: true, initial: 1 }),
equipped: new fields.BooleanField({ initial: false }), equipped: new fields.BooleanField({ initial: false }),
//SETTINGS //SETTINGS

View file

@ -19,4 +19,9 @@ export default class DhActiveEffect extends ActiveEffect {
await super._preCreate(data, options, user); 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);
}
} }

View file

@ -6,6 +6,8 @@
<fieldset class="two-columns"> <fieldset class="two-columns">
<legend>{{localize tabs.settings.label}}</legend> <legend>{{localize tabs.settings.label}}</legend>
<span>{{localize "DAGGERHEART.Tiers.singular"}}</span>
{{formField systemFields.tier value=source.system.tier}}
<span>{{localize "DAGGERHEART.Sheets.Armor.baseScore"}}</span> <span>{{localize "DAGGERHEART.Sheets.Armor.baseScore"}}</span>
{{formField systemFields.baseScore value=source.system.baseScore}} {{formField systemFields.baseScore value=source.system.baseScore}}

View file

@ -5,6 +5,8 @@
> >
<fieldset class="two-columns"> <fieldset class="two-columns">
<legend>{{localize tabs.settings.label}}</legend> <legend>{{localize tabs.settings.label}}</legend>
<span>{{localize "DAGGERHEART.Tiers.singular"}}</span>
{{formField systemFields.tier value=source.system.tier}}
<span>{{localize "DAGGERHEART.Sheets.Weapon.SecondaryWeapon"}}</span> <span>{{localize "DAGGERHEART.Sheets.Weapon.SecondaryWeapon"}}</span>
{{formField systemFields.secondary value=source.system.secondary}} {{formField systemFields.secondary value=source.system.secondary}}
<span>{{localize "DAGGERHEART.Sheets.Weapon.Trait"}}</span> <span>{{localize "DAGGERHEART.Sheets.Weapon.Trait"}}</span>