mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
[Fix] Homebrew Item Features (#1365)
* Fixed adding and editing effects on a homebrew feature * . * Fixed effect removal
This commit is contained in:
parent
cb10b18e06
commit
9fa4627b19
11 changed files with 411 additions and 252 deletions
|
|
@ -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;
|
||||
}, {})
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue