mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-24 08:23:38 +02:00
.
This commit is contained in:
parent
532c74a5bb
commit
535d2d92a7
1 changed files with 20 additions and 19 deletions
|
|
@ -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,25 +48,8 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
||||||
return { value: joined, label: getLabel(joined), group };
|
return { value: joined, label: getLabel(joined), group };
|
||||||
});
|
});
|
||||||
|
|
||||||
const getAllLeaves = (root, parentPath = '') => {
|
const bonuses = getAllLeaves(model.schema.fields.bonuses, group);
|
||||||
const leaves = [];
|
const rules = getAllLeaves(model.schema.fields.rules, group);
|
||||||
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, rootKey));
|
|
||||||
else
|
|
||||||
leaves.push({
|
|
||||||
value: `${rootKey}.${field.name}`,
|
|
||||||
label: game.i18n.localize(field.label),
|
|
||||||
hint: game.i18n.localize(field.hint),
|
|
||||||
group
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return leaves;
|
|
||||||
};
|
|
||||||
|
|
||||||
const bonuses = getAllLeaves(model.schema.fields.bonuses);
|
|
||||||
const rules = getAllLeaves(model.schema.fields.rules);
|
|
||||||
|
|
||||||
acc.push(...bars, ...values, ...rules, ...bonuses);
|
acc.push(...bars, ...values, ...rules, ...bonuses);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue