[Fix] ActiveEffect Autocomplete (#1641)

* Added rules and bonuses to ActiveEffect-autocomplete

* .
This commit is contained in:
WBHarry 2026-02-08 18:03:35 +01:00 committed by GitHub
parent 44131d21a6
commit f7e4c5346e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 137 additions and 18 deletions

View file

@ -192,6 +192,9 @@
}, },
"age": "Age", "age": "Age",
"backgroundQuestions": "Backgrounds", "backgroundQuestions": "Backgrounds",
"burden": {
"ignore": { "label": "Burden: Ignore", "hint": "Ignore burden rules" }
},
"companionFeatures": "Companion Features", "companionFeatures": "Companion Features",
"connections": "Connections", "connections": "Connections",
"contextMenu": { "contextMenu": {
@ -214,6 +217,12 @@
"maxEvasionBonus": "Max Evasion Increase", "maxEvasionBonus": "Max Evasion Increase",
"maxHPBonus": "Max HP Increase", "maxHPBonus": "Max HP Increase",
"pronouns": "Pronouns", "pronouns": "Pronouns",
"roll": {
"guaranteedCritical": {
"label": "Guaranteed Critical",
"hint": "Set to 1 to always roll a critical"
}
},
"story": { "story": {
"backgroundTitle": "Background", "backgroundTitle": "Background",
"characteristics": "Characteristics", "characteristics": "Characteristics",
@ -1840,6 +1849,16 @@
"singular": "Adversary", "singular": "Adversary",
"plural": "Adversaries" "plural": "Adversaries"
}, },
"Attack": {
"hpDamageMultiplier": {
"label": "HP Damage Multiplier",
"hint": "Multiply any damage you deal by this number"
},
"hpDamageTakenMultiplier": {
"label": "HP Damage Taken Multiplier",
"hint": "Multiply any damage dealt to you by this number"
}
},
"Bonuses": { "Bonuses": {
"rest": { "rest": {
"downtimeAction": "Downtime Action", "downtimeAction": "Downtime Action",
@ -2024,16 +2043,40 @@
"reaction": "Reaction Roll" "reaction": "Reaction Roll"
}, },
"Rules": { "Rules": {
"conditionImmunities": {
"hidden": "Condition Immunity: Hidden",
"restrained": "Condition Immunity: Restrained",
"vulnerable": "Condition Immunity: Vulnerable"
},
"damageReduction": { "damageReduction": {
"disabledArmor": { "label": "Disabled Armorslots" },
"increasePerArmorMark": { "increasePerArmorMark": {
"label": "Damage Reduction per Armor Slot", "label": "Damage Reduction per Armor Slot",
"hint": "A used armor slot normally reduces damage by one step. This value increases the number of steps damage is reduced by." "hint": "A used armor slot normally reduces damage by one step. This value increases the number of steps damage is reduced by."
}, },
"magical": {
"label": "Daamge Reduction: Only Magical",
"hint": "Armor can only be used to reduce magical damage"
},
"maxArmorMarkedBonus": "Max Armor Used", "maxArmorMarkedBonus": "Max Armor Used",
"maxArmorMarkedStress": { "maxArmorMarkedStress": {
"label": "Max Armor Used With Stress", "label": "Max Armor Used With Stress",
"hint": "If this value is set you can use up to that much stress to spend additional Armor Marks beyond your normal maximum." "hint": "If this value is set you can use up to that much stress to spend additional Armor Marks beyond your normal maximum."
}, },
"reduceSeverity": {
"magical": {
"label": "Reduce Damage Severity: Magical",
"hint": "Lowers any magical damage received by the set amount of severity degrees"
},
"physical": {
"label": "Reduce Damage Severity: Physical",
"hint": "Lowers any physical damage received by the set amount of severity degrees"
}
},
"physical": {
"label": "Damage Reduction: Only Physical",
"hint": "Armor can only be used to reduce physical damage"
},
"stress": { "stress": {
"any": { "any": {
"label": "Stress Damage Reduction: Any", "label": "Stress Damage Reduction: Any",
@ -2051,6 +2094,12 @@
"label": "Stress Damage Reduction: Minor", "label": "Stress Damage Reduction: Minor",
"hint": "The cost in stress you can pay to reduce minor damage to none." "hint": "The cost in stress you can pay to reduce minor damage to none."
} }
},
"thresholdImmunities": {
"minor": {
"label": "Threshold Immunities: Minor",
"hint": "Automatically ignores minor damage"
}
} }
}, },
"attack": { "attack": {

View file

@ -5,6 +5,24 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
super(options); super(options);
const ignoredActorKeys = ['config', 'DhEnvironment', 'DhParty']; const ignoredActorKeys = ['config', 'DhEnvironment', 'DhParty'];
const getAllLeaves = (root, group, parentPath = '') => {
const leaves = [];
const rootKey = `${parentPath ? `${parentPath}.` : ''}${root.name}`;
for (const field of Object.values(root.fields)) {
if (field instanceof foundry.data.fields.SchemaField)
leaves.push(...getAllLeaves(field, group, rootKey));
else
leaves.push({
value: `${rootKey}.${field.name}`,
label: game.i18n.localize(field.label),
hint: game.i18n.localize(field.hint),
group
});
}
return leaves;
};
this.changeChoices = Object.keys(game.system.api.models.actors).reduce((acc, key) => { this.changeChoices = Object.keys(game.system.api.models.actors).reduce((acc, key) => {
if (ignoredActorKeys.includes(key)) return acc; if (ignoredActorKeys.includes(key)) return acc;
@ -30,7 +48,10 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
return { value: joined, label: getLabel(joined), group }; return { value: joined, label: getLabel(joined), group };
}); });
acc.push(...bars, ...values); const bonuses = getAllLeaves(model.schema.fields.bonuses, group);
const rules = getAllLeaves(model.schema.fields.rules, group);
acc.push(...bars, ...values, ...rules, ...bonuses);
return acc; return acc;
}, []); }, []);

View file

@ -29,17 +29,40 @@ const resistanceField = (resistanceLabel, immunityLabel, reductionLabel) =>
/* Common rules applying to Characters and Adversaries */ /* Common rules applying to Characters and Adversaries */
export const commonActorRules = (extendedData = { damageReduction: {}, attack: { damage: {} } }) => ({ export const commonActorRules = (extendedData = { damageReduction: {}, attack: { damage: {} } }) => ({
conditionImmunities: new fields.SchemaField({ conditionImmunities: new fields.SchemaField({
hidden: new fields.BooleanField({ initial: false }), hidden: new fields.BooleanField({
restrained: new fields.BooleanField({ initial: false }), initial: false,
vulnerable: new fields.BooleanField({ initial: false }) label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.hidden'
}),
restrained: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.restrained'
}),
vulnerable: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.vulnerable'
})
}), }),
damageReduction: new fields.SchemaField({ damageReduction: new fields.SchemaField({
thresholdImmunities: new fields.SchemaField({ thresholdImmunities: new fields.SchemaField({
minor: new fields.BooleanField({ initial: false }) minor: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.thresholdImmunities.minor.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.thresholdImmunities.minor.hint'
})
}), }),
reduceSeverity: new fields.SchemaField({ reduceSeverity: new fields.SchemaField({
magical: new fields.NumberField({ initial: 0, min: 0 }), magical: new fields.NumberField({
physical: new fields.NumberField({ initial: 0, min: 0 }) initial: 0,
min: 0,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.reduceSeverity.magical.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.reduceSeverity.magical.hint'
}),
physical: new fields.NumberField({
initial: 0,
min: 0,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.reduceSeverity.physical.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.reduceSeverity.physical.hint'
})
}), }),
...(extendedData.damageReduction ?? {}) ...(extendedData.damageReduction ?? {})
}), }),
@ -49,12 +72,16 @@ export const commonActorRules = (extendedData = { damageReduction: {}, attack: {
hpDamageMultiplier: new fields.NumberField({ hpDamageMultiplier: new fields.NumberField({
required: true, required: true,
nullable: false, nullable: false,
initial: 1 initial: 1,
label: 'DAGGERHEART.GENERAL.Attack.hpDamageMultiplier.label',
hint: 'DAGGERHEART.GENERAL.Attack.hpDamageMultiplier.hint'
}), }),
hpDamageTakenMultiplier: new fields.NumberField({ hpDamageTakenMultiplier: new fields.NumberField({
required: true, required: true,
nullable: false, nullable: false,
initial: 1 initial: 1,
label: 'DAGGERHEART.GENERAL.Attack.hpDamageTakenMultiplier.label',
hint: 'DAGGERHEART.GENERAL.Attack.hpDamageTakenMultiplier.hint'
}), }),
...(extendedData.attack?.damage ?? {}) ...(extendedData.attack?.damage ?? {})
}) })

View file

@ -225,8 +225,16 @@ export default class DhCharacter extends BaseDataActor {
rules: new fields.SchemaField({ rules: new fields.SchemaField({
...commonActorRules({ ...commonActorRules({
damageReduction: { damageReduction: {
magical: new fields.BooleanField({ initial: false }), magical: new fields.BooleanField({
physical: new fields.BooleanField({ initial: false }), initial: false,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.magical.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.magical.hint'
}),
physical: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.physical.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.physical.hint'
}),
maxArmorMarked: new fields.SchemaField({ maxArmorMarked: new fields.SchemaField({
value: new fields.NumberField({ value: new fields.NumberField({
required: true, required: true,
@ -256,7 +264,10 @@ export default class DhCharacter extends BaseDataActor {
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.increasePerArmorMark.label', label: 'DAGGERHEART.GENERAL.Rules.damageReduction.increasePerArmorMark.label',
hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.increasePerArmorMark.hint' hint: 'DAGGERHEART.GENERAL.Rules.damageReduction.increasePerArmorMark.hint'
}), }),
disabledArmor: new fields.BooleanField({ intial: false }) disabledArmor: new fields.BooleanField({
intial: false,
label: 'DAGGERHEART.GENERAL.Rules.damageReduction.disabledArmor.label'
})
}, },
attack: { attack: {
damage: { damage: {
@ -304,12 +315,14 @@ export default class DhCharacter extends BaseDataActor {
label: 'DAGGERHEART.ACTORS.Character.defaultFearDice' label: 'DAGGERHEART.ACTORS.Character.defaultFearDice'
}) })
}), }),
runeWard: new fields.BooleanField({ initial: false }),
burden: new fields.SchemaField({ burden: new fields.SchemaField({
ignore: new fields.BooleanField() ignore: new fields.BooleanField({ label: 'DAGGERHEART.ACTORS.Character.burden.ignore.label' })
}), }),
roll: new fields.SchemaField({ roll: new fields.SchemaField({
guaranteedCritical: new fields.BooleanField() guaranteedCritical: new fields.BooleanField({
label: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.label',
hint: 'DAGGERHEART.ACTORS.Character.roll.guaranteedCritical.hint'
})
}) })
}) })
}; };

View file

@ -53,9 +53,18 @@ export default class DhCompanion extends BaseDataActor {
), ),
rules: new fields.SchemaField({ rules: new fields.SchemaField({
conditionImmunities: new fields.SchemaField({ conditionImmunities: new fields.SchemaField({
hidden: new fields.BooleanField({ initial: false }), hidden: new fields.BooleanField({
restrained: new fields.BooleanField({ initial: false }), initial: false,
vulnerable: new fields.BooleanField({ initial: false }) label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.hidden'
}),
restrained: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.restrained'
}),
vulnerable: new fields.BooleanField({
initial: false,
label: 'DAGGERHEART.GENERAL.Rules.conditionImmunities.vulnerable'
})
}) })
}), }),
attack: new ActionField({ attack: new ActionField({