mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Compare commits
3 commits
22f38d796b
...
b08b8b93b6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b08b8b93b6 | ||
|
|
104616bc3d | ||
|
|
fc60305a44 |
5 changed files with 30 additions and 13 deletions
|
|
@ -102,11 +102,7 @@ export default class DhActorDirectory extends foundry.applications.sidebar.tabs.
|
|||
const actor = game.actors.get(li.dataset.entryId);
|
||||
if (!actor) throw new Error('Unexpected missing actor');
|
||||
|
||||
const currentActiveParty = game.actors.find(x => x.type === 'party' && x.system.active);
|
||||
if (currentActiveParty)
|
||||
await currentActiveParty.update({ 'system.active': false });
|
||||
|
||||
await actor.update({ 'system.active': true });
|
||||
await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, actor.id);
|
||||
ui.actors.render();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ export const gameSettings = {
|
|||
LastMigrationVersion: 'LastMigrationVersion',
|
||||
SpotlightRequestQueue: 'SpotlightRequestQueue',
|
||||
CompendiumBrowserSettings: 'CompendiumBrowserSettings',
|
||||
SpotlightTracker: 'SpotlightTracker'
|
||||
SpotlightTracker: 'SpotlightTracker',
|
||||
ActiveParty: 'ActiveParty',
|
||||
};
|
||||
|
||||
export const actionAutomationChoices = {
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
@ -45,13 +48,21 @@ export default class DhParty extends BaseDataActor {
|
|||
}
|
||||
}
|
||||
|
||||
/**@inheritdoc */
|
||||
async _preCreate(data, options, user) {
|
||||
const allowed = await super._preCreate(data, options, user);
|
||||
if (allowed === false) return;
|
||||
_onCreate(data, options, userId) {
|
||||
super._onCreate(data, options, userId);
|
||||
|
||||
if (!game.actors.some(x => x.type === 'party' && x.active))
|
||||
await this.updateSource({ active: true });
|
||||
if (game.user.isActiveGM && !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).then(_ => {
|
||||
ui.actors.render();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async _preDelete() {
|
||||
super._preDelete();
|
||||
|
||||
if (this.active)
|
||||
game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, null);
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ export default class DhpActor extends Actor {
|
|||
game.system.registeredTriggers.unregisterItemTriggers(token.actor.items);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.system._preDelete() === false) return false;
|
||||
}
|
||||
|
||||
_onDelete(options, userId) {
|
||||
|
|
|
|||
|
|
@ -189,4 +189,11 @@ const registerNonConfigSettings = () => {
|
|||
config: false,
|
||||
type: SpotlightTracker
|
||||
});
|
||||
|
||||
game.settings.register(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.ActiveParty, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: String,
|
||||
default: null,
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue