Fixed so that Homebrew Item Features without effects don't error out because effects are expected

This commit is contained in:
WBHarry 2026-04-23 22:51:54 +02:00
parent d73760fc39
commit 41829bc9d5
2 changed files with 5 additions and 4 deletions

View file

@ -188,8 +188,9 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
if (type === 'effect') {
const move = foundry.utils.getProperty(this.settings, this.movePath);
for (const action of move.actions) {
const remainingEffects = action.effects.filter(x => x._id !== id);
if (action.effects.length !== remainingEffects.length) {
const actionEffects = action.effects ?? [];
const remainingEffects = actionEffects.filter(x => x._id !== id);
if (actionEffects.length !== remainingEffects.length) {
await action.update({
effects: remainingEffects.map(x => {
const { _id, ...rest } = x;

View file

@ -453,7 +453,7 @@ export const allArmorFeatures = () => {
const feature = homebrewFeatures[key];
const actions = feature.actions.map(action => ({
...action,
effects: action.effects.map(effect => feature.effects.find(x => x.id === effect._id)),
effects: action.effects?.map(effect => feature.effects.find(x => x.id === effect._id))??[],
type: action.type
}));
const actionEffects = actions.flatMap(a => a.effects);
@ -1407,7 +1407,7 @@ export const allWeaponFeatures = () => {
const actions = feature.actions.map(action => ({
...action,
effects: action.effects.map(effect => feature.effects.find(x => x.id === effect._id)),
effects: action.effects?.map(effect => feature.effects.find(x => x.id === effect._id)) ?? [],
type: action.type
}));
const actionEffects = actions.flatMap(a => a.effects);