[Feature] Active Party (#1803)

This commit is contained in:
WBHarry 2026-04-16 02:26:39 +02:00 committed by GitHub
parent 8808e4646d
commit 7d5cdeb09d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 179 additions and 71 deletions

View file

@ -18,6 +18,10 @@ export default class DhParty extends BaseDataActor {
};
}
get active() {
return game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty) === this.parent.id;
}
/* -------------------------------------------- */
/**@inheritdoc */
@ -40,6 +44,16 @@ export default class DhParty extends BaseDataActor {
}
}
_onCreate(data, options, userId) {
super._onCreate(data, options, userId);
if (game.user.isActiveGM && !game.actors.party) {
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, this.parent.id).then(_ => {
ui.actors.render();
});
}
}
_onDelete(options, userId) {
super._onDelete(options, userId);
@ -47,5 +61,11 @@ export default class DhParty extends BaseDataActor {
for (const member of this.partyMembers) {
member?.parties?.delete(this.parent);
}
// If this *was* the active party, delete it. We can't use game.actors.party as this actor was already deleted
const isWorldActor = !this.parent?.parent && !this.parent.compendium;
const activePartyId = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty);
if (isWorldActor && this.id === activePartyId)
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, null);
}
}