mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed effect removal
This commit is contained in:
parent
378c6b4c67
commit
1da5d7a1f7
3 changed files with 35 additions and 22 deletions
|
|
@ -2385,7 +2385,7 @@
|
||||||
"downtimeMove": "Downtime Move",
|
"downtimeMove": "Downtime Move",
|
||||||
"armorFeature": "Armor Feature",
|
"armorFeature": "Armor Feature",
|
||||||
"weaponFeature": "Weapon Feature",
|
"weaponFeature": "Weapon Feature",
|
||||||
"newFeature": "New ItemFeature",
|
"newFeature": "New Item Feature",
|
||||||
"downtimeMoves": "Downtime Moves",
|
"downtimeMoves": "Downtime Moves",
|
||||||
"itemFeatures": "Item Features",
|
"itemFeatures": "Item Features",
|
||||||
"nrChoices": "# Moves Per Rest",
|
"nrChoices": "# Moves Per Rest",
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,8 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
|
||||||
return (
|
return (
|
||||||
(await foundry.applications.api.DialogV2.input({
|
(await foundry.applications.api.DialogV2.input({
|
||||||
window: { title: game.i18n.localize('DAGGERHEART.CONFIG.SelectAction.selectType') },
|
window: { title: game.i18n.localize('DAGGERHEART.CONFIG.SelectAction.selectType') },
|
||||||
|
position: { width: 300 },
|
||||||
|
classes: ['daggerheart', 'dh-style'],
|
||||||
content: await foundry.applications.handlebars.renderTemplate(
|
content: await foundry.applications.handlebars.renderTemplate(
|
||||||
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
'systems/daggerheart/templates/actionTypes/actionType.hbs',
|
||||||
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
{ types: CONFIG.DH.ACTIONS.actionTypes }
|
||||||
|
|
@ -185,7 +187,24 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
|
||||||
static async removeItem(_, target) {
|
static async removeItem(_, target) {
|
||||||
const { type, id } = target.dataset;
|
const { type, id } = target.dataset;
|
||||||
if (type === 'effect') {
|
if (type === 'effect') {
|
||||||
await this.settings.updateSource({ [`${this.movePath}.effects.-=${id}`]: null });
|
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) {
|
||||||
|
await action.update({
|
||||||
|
effects: remainingEffects.map(x => {
|
||||||
|
const { _id, ...rest } = x;
|
||||||
|
return { ...rest, _id: _id };
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await this.settings.updateSource({
|
||||||
|
[this.movePath]: {
|
||||||
|
effects: move.effects.filter(x => x.id !== id),
|
||||||
|
actions: move.actions
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
await this.settings.updateSource({ [`${this.actionsPath}.-=${target.dataset.id}`]: null });
|
await this.settings.updateSource({ [`${this.actionsPath}.-=${target.dataset.id}`]: null });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -459,16 +459,13 @@ export const allArmorFeatures = () => {
|
||||||
...armorFeatures,
|
...armorFeatures,
|
||||||
...Object.keys(homebrewFeatures).reduce((acc, key) => {
|
...Object.keys(homebrewFeatures).reduce((acc, key) => {
|
||||||
const feature = homebrewFeatures[key];
|
const feature = homebrewFeatures[key];
|
||||||
const actionEffects = [];
|
const actions = feature.actions.map(action => ({
|
||||||
const actions = feature.actions.map(action => {
|
...action,
|
||||||
const 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)),
|
||||||
actionEffects.push(...effects);
|
type: action.type
|
||||||
return {
|
}));
|
||||||
...action,
|
const actionEffects = actions.flatMap(a => a.effects);
|
||||||
effects: effects,
|
|
||||||
type: action.type
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
|
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
|
||||||
|
|
||||||
acc[key] = { ...feature, label: feature.name, effects, actions };
|
acc[key] = { ...feature, label: feature.name, effects, actions };
|
||||||
|
|
@ -1431,16 +1428,13 @@ export const allWeaponFeatures = () => {
|
||||||
...weaponFeatures,
|
...weaponFeatures,
|
||||||
...Object.keys(homebrewFeatures).reduce((acc, key) => {
|
...Object.keys(homebrewFeatures).reduce((acc, key) => {
|
||||||
const feature = homebrewFeatures[key];
|
const feature = homebrewFeatures[key];
|
||||||
const actionEffects = [];
|
|
||||||
const actions = feature.actions.map(action => {
|
const actions = feature.actions.map(action => ({
|
||||||
const effects = action.effects.map(effect => feature.effects.find(x => x.id === effect._id));
|
...action,
|
||||||
actionEffects.push(...effects);
|
effects: action.effects.map(effect => feature.effects.find(x => x.id === effect._id)),
|
||||||
return {
|
type: action.type
|
||||||
...action,
|
}));
|
||||||
effects: effects,
|
const actionEffects = actions.flatMap(a => a.effects);
|
||||||
type: action.type
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
|
const effects = feature.effects.filter(effect => !actionEffects.some(x => x.id === effect.id));
|
||||||
|
|
||||||
acc[key] = { ...feature, label: feature.name, effects, actions };
|
acc[key] = { ...feature, label: feature.name, effects, actions };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue