mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Changed to use a world setting to store the active party id
This commit is contained in:
parent
fc60305a44
commit
104616bc3d
4 changed files with 23 additions and 7 deletions
|
|
@ -9,7 +9,6 @@ export default class DhParty extends BaseDataActor {
|
|||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
active: new fields.BooleanField(),
|
||||
partyMembers: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { prune: true }),
|
||||
notes: new fields.HTMLField(),
|
||||
gold: new fields.SchemaField({
|
||||
|
|
@ -23,6 +22,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 */
|
||||
|
|
@ -50,8 +53,15 @@ export default class DhParty extends BaseDataActor {
|
|||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
|
||||
if (!game.actors.some(x => x.type === 'party' && x.active))
|
||||
await this.updateSource({ active: true });
|
||||
if (!game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty))
|
||||
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, this.parent.id);
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
super._preDelete();
|
||||
|
||||
if (this.active)
|
||||
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, null);
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue