mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-14 20:51:07 +01:00
Fixed deletion of characters in the world locking up the party actor
This commit is contained in:
parent
63e66bd0d3
commit
013085299f
5 changed files with 36 additions and 4 deletions
|
|
@ -2660,7 +2660,8 @@
|
||||||
"subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class.",
|
"subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class.",
|
||||||
"gmRequired": "This action requires an online GM",
|
"gmRequired": "This action requires an online GM",
|
||||||
"gmOnly": "This can only be accessed by the GM",
|
"gmOnly": "This can only be accessed by the GM",
|
||||||
"noActorOwnership": "You do not have permissions for this character"
|
"noActorOwnership": "You do not have permissions for this character",
|
||||||
|
"documentIsMissing": "The {documentType} is missing from the world."
|
||||||
},
|
},
|
||||||
"Sidebar": {
|
"Sidebar": {
|
||||||
"daggerheartMenu": {
|
"daggerheartMenu": {
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,14 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
const { actor: actorData, trait } = foundry.utils.getProperty(message.system, path);
|
const { actor: actorData, trait } = foundry.utils.getProperty(message.system, path);
|
||||||
const actor = game.actors.get(actorData._id);
|
const actor = game.actors.get(actorData._id);
|
||||||
|
|
||||||
|
if (!actor) {
|
||||||
|
return ui.notifications.error(
|
||||||
|
game.i18n.format('DAGGERHEART.UI.Notifications.documentIsMissing', {
|
||||||
|
documentType: game.i18n.localize('TYPES.Actor.character')
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!actor.testUserPermission(game.user, 'OWNER')) {
|
if (!actor.testUserPermission(game.user, 'OWNER')) {
|
||||||
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
|
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
|
||||||
}
|
}
|
||||||
|
|
@ -225,6 +233,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!result) return;
|
||||||
|
|
||||||
const newMessageData = foundry.utils.deepClone(message.system);
|
const newMessageData = foundry.utils.deepClone(message.system);
|
||||||
foundry.utils.setProperty(newMessageData, `${path}.result`, result.roll);
|
foundry.utils.setProperty(newMessageData, `${path}.result`, result.roll);
|
||||||
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
|
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
|
||||||
|
|
|
||||||
|
|
@ -672,9 +672,19 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
if (this.companion) {
|
if (this.companion) {
|
||||||
this.companion.updateLevel(1);
|
this.companion.updateLevel(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.parent.parties) {
|
||||||
|
for (const party of this.parent.parties) {
|
||||||
|
await party.update({
|
||||||
|
'system.partyMembers': party.system.partyMembers.filter(x => x.uuid !== this.parent.uuid)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_getTags() {
|
_getTags() {
|
||||||
return [this.class.value?.name, this.class.subclass?.name, this.community?.name, this.ancestry?.name].filter((t) => !!t);
|
return [this.class.value?.name, this.class.subclass?.name, this.community?.name, this.ancestry?.name].filter(
|
||||||
|
t => !!t
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export default class DhParty extends BaseDataActor {
|
||||||
// Register this party to all members
|
// Register this party to all members
|
||||||
if (game.actors.get(this.parent.id) === this.parent) {
|
if (game.actors.get(this.parent.id) === this.parent) {
|
||||||
for (const member of this.partyMembers) {
|
for (const member of this.partyMembers) {
|
||||||
member.parties?.add(this.parent);
|
member?.parties?.add(this.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ export default class DhParty extends BaseDataActor {
|
||||||
|
|
||||||
// Clear this party from all members that aren't deleted
|
// Clear this party from all members that aren't deleted
|
||||||
for (const member of this.partyMembers) {
|
for (const member of this.partyMembers) {
|
||||||
member.parties?.delete(this.parent);
|
member?.parties?.delete(this.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ export async function runMigrations() {
|
||||||
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
|
let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion);
|
||||||
if (!lastMigrationVersion) lastMigrationVersion = game.system.version;
|
if (!lastMigrationVersion) lastMigrationVersion = game.system.version;
|
||||||
|
|
||||||
|
//#region old migrations
|
||||||
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
if (foundry.utils.isNewerVersion('1.1.0', lastMigrationVersion)) {
|
||||||
const lockedPacks = [];
|
const lockedPacks = [];
|
||||||
const compendiumActors = [];
|
const compendiumActors = [];
|
||||||
|
|
@ -190,6 +191,16 @@ export async function runMigrations() {
|
||||||
|
|
||||||
lastMigrationVersion = '1.2.0';
|
lastMigrationVersion = '1.2.0';
|
||||||
}
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
|
if (foundry.utils.isNewerVersion('1.2.2', lastMigrationVersion)) {
|
||||||
|
/* Delete any null party members caused by characters being deleted in the world prior to it being handled */
|
||||||
|
for (let party of game.actors.filter(x => x.type === 'party')) {
|
||||||
|
await party.update({ 'system.partyMembers': party.system.partyMembers.filter(x => x) });
|
||||||
|
}
|
||||||
|
|
||||||
|
lastMigrationVersion = '1.2.2';
|
||||||
|
}
|
||||||
|
|
||||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion, lastMigrationVersion);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue