Update armor slot handling

This commit is contained in:
Dapoolp 2025-09-02 14:26:50 +02:00
parent 4bdafeff6d
commit af3a415e56
10 changed files with 56 additions and 72 deletions

View file

@ -9,13 +9,6 @@ export default class DHToken extends TokenDocument {
const barGroup = game.i18n.localize('TOKEN.BarAttributes');
const valueGroup = game.i18n.localize('TOKEN.BarValues');
const bars = attributes.bar.map(v => {
const a = v.join('.');
const modelLabel = model ? game.i18n.localize(model.schema.getField(`${a}.value`).label) : null;
return { group: barGroup, value: a, label: modelLabel ? modelLabel : a };
});
bars.sort((a, b) => a.label.compare(b.label));
const invalidAttributes = [
'gold',
'levelData',
@ -29,8 +22,21 @@ export default class DHToken extends TokenDocument {
'description',
'impulses',
'tier',
'type'
'type',
'resources.armor'
];
const bars = attributes.bar.reduce((acc, v) => {
const a = v.join('.');
if (invalidAttributes.some(x => a.startsWith(x))) return acc;
const modelLabel = model ? game.i18n.localize(model.schema.getField(`${a}.value`).label) : null;
acc.push({ group: barGroup, value: a, label: modelLabel ? modelLabel : a });
return acc;
}, []);
bars.sort((a, b) => a.label.compare(b.label));
const values = attributes.value.reduce((acc, v) => {
const a = v.join('.');
if (invalidAttributes.some(x => a.startsWith(x))) return acc;