mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
[Feature] Active Party (#1803)
This commit is contained in:
parent
8808e4646d
commit
7d5cdeb09d
12 changed files with 179 additions and 71 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue