mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 19:51:08 +01:00
.
This commit is contained in:
parent
49adeed8c5
commit
83709e334d
8 changed files with 63 additions and 17 deletions
|
|
@ -10,6 +10,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
this.data = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
this.editingCountdowns = new Set();
|
||||
this.currentEditCountdown = null;
|
||||
this.hideNewCountdowns = false;
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
|
@ -45,6 +46,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
context.defaultOwnership = this.data.defaultOwnership;
|
||||
context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes;
|
||||
context.countdownTypes = CONFIG.DH.GENERAL.countdownTypes;
|
||||
context.hideNewCountdowns = this.hideNewCountdowns;
|
||||
context.countdowns = Object.keys(this.data.countdowns).reduce((acc, key) => {
|
||||
const countdown = this.data.countdowns[key];
|
||||
acc[key] = {
|
||||
|
|
@ -107,7 +109,9 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
}
|
||||
|
||||
static async updateData(_event, _, formData) {
|
||||
this.updateSetting(foundry.utils.expandObject(formData.object));
|
||||
const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object);
|
||||
this.hideNewCountdowns = hideNewCountdowns;
|
||||
this.updateSetting(settingsData);
|
||||
}
|
||||
|
||||
async gmSetSetting(data) {
|
||||
|
|
@ -124,7 +128,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
this.editingCountdowns.add(id);
|
||||
this.currentEditCountdown = id;
|
||||
this.updateSetting({
|
||||
[`countdowns.${id}`]: DhCountdown.defaultCountdown()
|
||||
[`countdowns.${id}`]: DhCountdown.defaultCountdown(null, this.hideNewCountdowns)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,11 +100,12 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
}
|
||||
return acc;
|
||||
}, []);
|
||||
const nonGmPlayers = game.users.filter(x => !x.isGM);
|
||||
acc[key] = {
|
||||
...countdown,
|
||||
editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER,
|
||||
playerAccess:
|
||||
playersWithAccess.length !== game.users.filter(x => !x.isGM).length ? playersWithAccess : []
|
||||
playerAccess: playersWithAccess.length !== nonGmPlayers.length ? playersWithAccess : [],
|
||||
noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
@ -114,7 +115,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
|
||||
static #getPlayerOwnership(user, setting, countdown) {
|
||||
const playerOwnership = countdown.ownership[user.id];
|
||||
return playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT ? setting.defaultOwnership : playerOwnership;
|
||||
return playerOwnership === undefined || playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
|
||||
? setting.defaultOwnership
|
||||
: playerOwnership;
|
||||
}
|
||||
|
||||
toggleCollapsedPosition = async (_, collapsed) => {
|
||||
|
|
|
|||
|
|
@ -181,11 +181,21 @@ export class DhCountdown extends foundry.abstract.DataModel {
|
|||
};
|
||||
}
|
||||
|
||||
static defaultCountdown(type) {
|
||||
static defaultCountdown(type, playerHidden) {
|
||||
const ownership = playerHidden
|
||||
? game.users.reduce((acc, user) => {
|
||||
if (!user.isGM) {
|
||||
acc[user.id] = CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE;
|
||||
}
|
||||
return acc;
|
||||
}, {})
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
type: type ?? CONFIG.DH.GENERAL.countdownBaseTypes.narrative.id,
|
||||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Countdown.newCountdown'),
|
||||
img: 'icons/magic/time/hourglass-yellow-green.webp',
|
||||
ownership: ownership,
|
||||
progress: {
|
||||
current: 1,
|
||||
max: 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue