[Fix] Party And Effect Minifixes (#1337)

* .

* Added migration to remove ghosts from the TagTeamDialog
This commit is contained in:
WBHarry 2025-11-25 23:20:07 +01:00 committed by GitHub
parent d616ddc113
commit 44b805d0df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 2 deletions

View file

@ -106,6 +106,21 @@ export default class BaseDataActor extends foundry.abstract.TypeDataModel {
return data;
}
async _preDelete() {
/* Clear all partyMembers from tagTeam setting.*/
/* Revisit this when tagTeam is improved for many parties */
if (this.parent.parties.size > 0) {
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 }
: {}
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
}
}
async _preUpdate(changes, options, userId) {
const allowed = await super._preUpdate(changes, options, userId);
if (allowed === false) return;

View file

@ -678,6 +678,8 @@ export default class DhCharacter extends BaseDataActor {
}
async _preDelete() {
super._preDelete();
if (this.companion) {
this.companion.updateLevel(1);
}

View file

@ -36,6 +36,23 @@ export default class DhParty extends BaseDataActor {
}
}
async _preDelete() {
/* Clear all partyMembers from tagTeam setting.*/
/* Revisit this when tagTeam is improved for many parties */
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
await tagTeam.updateSource({
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;
}
return acc;
}, {})
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
}
_onDelete(options, userId) {
super._onDelete(options, userId);

View file

@ -51,7 +51,7 @@ export default class EffectsField extends fields.ArrayField {
let effects = this.effects;
const messageTargets = [];
targets.forEach(async baseToken => {
if (this.hasSave && token.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
if (this.hasSave && baseToken.saved.success === true) effects = this.effects.filter(e => e.onSave === true);
if (!effects.length) return;
const token =

View file

@ -191,6 +191,25 @@ export async function runMigrations() {
lastMigrationVersion = '1.2.0';
}
if (foundry.utils.isNewerVersion('1.2.7', lastMigrationVersion)) {
const tagTeam = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll);
const initatorMissing = tagTeam.initiator && !game.actors.some(actor => actor.id === tagTeam.initiator);
const missingMembers = Object.keys(tagTeam.members).reduce((acc, id) => {
if (!game.actors.some(actor => actor.id === id)) {
acc[`-=${id}`] = null;
}
return acc;
}, {});
await tagTeam.updateSource({
initiator: initatorMissing ? null : tagTeam.initiator,
members: missingMembers
});
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll, tagTeam);
lastMigrationVersion = '1.2.7';
}
//#endregion
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);

View file

@ -2,7 +2,7 @@
"id": "daggerheart",
"title": "Daggerheart",
"description": "An unofficial implementation of the Daggerheart system",
"version": "1.2.6",
"version": "1.2.7",
"compatibility": {
"minimum": "13",
"verified": "13.351",