Updated from special database update syntax to DataFieldOperators

This commit is contained in:
WBHarry 2026-01-31 18:31:10 +01:00
parent 9553f3387f
commit cd52aa8f9c
25 changed files with 42 additions and 45 deletions

View file

@ -100,7 +100,7 @@ export default class BeastformEffect extends BaseEffect {
token.flags.daggerheart?.beastformSubjectTexture ?? this.characterTokenData.tokenRingImg
}
},
'flags.daggerheart': { '-=beastformTokenImg': null, '-=beastformSubjectTexture': null }
'flags.daggerheart': { beastformTokenImg: _del, beastformSubjectTexture: _del }
};
};

View file

@ -169,9 +169,7 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
await tagTeam.updateSource({
initiator: this.parent.id === tagTeam.initiator ? null : tagTeam.initiator,
members: Object.keys(tagTeam.members).find(x => x === this.parent.id)
? { [`-=${this.parent.id}`]: null }
: {}
members: Object.keys(tagTeam.members).find(x => x === this.parent.id) ? { [this.parent.id]: _del } : {}
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
}

View file

@ -48,7 +48,7 @@ export default class DhParty extends BaseDataActor {
initiator: this.partyMembers.some(x => x.id === tagTeam.initiator) ? null : tagTeam.initiator,
members: Object.keys(tagTeam.members).reduce((acc, key) => {
if (this.partyMembers.find(x => x.id === key)) {
acc[`-=${key}`] = null;
acc[key] = _del;
}
return acc;

View file

@ -243,11 +243,11 @@ export function ActionMixin(Base) {
: foundry.utils.getProperty(result, basePath);
}
delete() {
async delete() {
if (!this.inCollection) return this.item;
const action = foundry.utils.getProperty(this.item, `system.${this.systemPath}`)?.get(this.id);
if (!action) return this.item;
this.item.update({ [`system.${this.systemPath}.-=${this.id}`]: null });
await this.item.update({ [`system.${this.systemPath}.${this.id}`]: _del }); // Does not work. Unsure why. It worked in v13 <_<'
this.constructor._sheets.get(this.uuid)?.close();
}

View file

@ -87,7 +87,7 @@ export default class DHArmor extends AttachableItem {
}
await this.parent.deleteEmbeddedDocuments('ActiveEffect', effectIds);
changes.system.actions = actionIds.reduce((acc, id) => {
acc[`-=${id}`] = null;
acc[id] = _del;
return acc;
}, {});

View file

@ -230,9 +230,9 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
if (changed.system?.actions) {
const triggersToRemove = Object.keys(changed.system.actions).reduce((acc, key) => {
if (!changed.system.actions[key]) {
const strippedKey = key.replace('-=', '');
acc.push(...this.actions.get(strippedKey).triggers.map(x => x.trigger));
const action = changed.system.actions[key];
if (action && Object.keys(action).length === 0) {
acc.push(...this.actions.get(key).triggers.map(x => x.trigger));
}
return acc;

View file

@ -147,7 +147,7 @@ export default class DHWeapon extends AttachableItem {
await this.parent.deleteEmbeddedDocuments('ActiveEffect', removedEffectsUpdate);
changes.system.actions = removedActionsUpdate.reduce((acc, id) => {
acc[`-=${id}`] = null;
acc[id] = _del;
return acc;
}, {});