mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-11 03:27:08 +01:00
Merge branch 'main' into fix/party-fixies
This commit is contained in:
commit
07c228dbad
32 changed files with 172 additions and 166 deletions
|
|
@ -88,6 +88,17 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded);
|
||||
}
|
||||
|
||||
/** Returns countdown data filtered by ownership */
|
||||
#getCountdowns() {
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({
|
||||
key,
|
||||
countdown,
|
||||
ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown)
|
||||
}));
|
||||
return values.filter((v) => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE);
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
|
@ -98,11 +109,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
||||
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
context.countdowns = Object.keys(setting.countdowns).reduce((acc, key) => {
|
||||
const countdown = setting.countdowns[key];
|
||||
const ownership = DhCountdowns.#getPlayerOwnership(game.user, setting, countdown);
|
||||
if (ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) return acc;
|
||||
|
||||
context.countdowns = this.#getCountdowns().reduce((acc, { key, countdown, ownership }) => {
|
||||
const playersWithAccess = game.users.reduce((acc, user) => {
|
||||
const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown);
|
||||
if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
|
||||
|
|
@ -238,4 +245,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
});
|
||||
Hooks.callAll(socketEvent.Refresh, data);
|
||||
}
|
||||
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default class DhParty extends BaseDataActor {
|
|||
const fields = foundry.data.fields;
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
partyMembers: new ForeignDocumentUUIDArrayField({ type: 'Actor' }),
|
||||
partyMembers: new ForeignDocumentUUIDArrayField({ type: 'Actor' }, { prune: true }),
|
||||
notes: new fields.HTMLField(),
|
||||
gold: new fields.SchemaField({
|
||||
coins: new fields.NumberField({ initial: 0, integer: true }),
|
||||
|
|
@ -27,7 +27,6 @@ export default class DhParty extends BaseDataActor {
|
|||
|
||||
prepareBaseData() {
|
||||
super.prepareBaseData();
|
||||
this.partyMembers = this.partyMembers.filter(p => !!p);
|
||||
|
||||
// Register this party to all members
|
||||
if (game.actors.get(this.parent.id) === this.parent) {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ export default class ForeignDocumentUUIDArrayField extends foundry.data.fields.A
|
|||
/** @inheritdoc */
|
||||
initialize(value, model, options = {}) {
|
||||
const v = super.initialize(value, model, options);
|
||||
return () => v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
||||
return () => {
|
||||
const data = v.map(entry => (typeof entry === 'function' ? entry() : entry));
|
||||
return this.options.prune ? data.filter((d) => !!d) : d;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue