[Fix] Homebrew Item Features (#1365)

* Fixed adding and editing effects on a homebrew feature

* .

* Fixed effect removal
This commit is contained in:
WBHarry 2025-12-06 02:29:56 +01:00 committed by GitHub
parent cb10b18e06
commit 9fa4627b19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 411 additions and 252 deletions

View file

@ -459,7 +459,16 @@ export const allArmorFeatures = () => {
...armorFeatures,
...Object.keys(homebrewFeatures).reduce((acc, key) => {
const feature = homebrewFeatures[key];
acc[key] = { ...feature, label: feature.name };
const actions = feature.actions.map(action => ({
...action,
effects: action.effects.map(effect => feature.effects.find(x => x.id === effect._id)),
type: action.type
}));
const actionEffects = actions.flatMap(a => a.effects);
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
acc[key] = { ...feature, label: feature.name, effects, actions };
return acc;
}, {})
};
@ -1414,11 +1423,21 @@ export const weaponFeatures = {
export const allWeaponFeatures = () => {
const homebrewFeatures = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).itemFeatures
.weaponFeatures;
return {
...weaponFeatures,
...Object.keys(homebrewFeatures).reduce((acc, key) => {
const feature = homebrewFeatures[key];
acc[key] = { ...feature, label: feature.name };
const actions = feature.actions.map(action => ({
...action,
effects: action.effects.map(effect => feature.effects.find(x => x.id === effect._id)),
type: action.type
}));
const actionEffects = actions.flatMap(a => a.effects);
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
acc[key] = { ...feature, label: feature.name, effects, actions };
return acc;
}, {})
};