mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
organize countdown
This commit is contained in:
parent
d16d01c943
commit
5b0b1023f6
1 changed files with 26 additions and 10 deletions
|
|
@ -106,7 +106,10 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
|
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
|
||||||
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
||||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||||
context.countdowns = this.#getCountdowns().reduce((acc, { key, countdown, ownership }) => {
|
|
||||||
|
const allCountdowns = this.#getCountdowns();
|
||||||
|
|
||||||
|
const { longTermCountdowns, otherCountdowns } = allCountdowns.reduce((acc, { key, countdown, ownership }) => {
|
||||||
const playersWithAccess = game.users.reduce((acc, user) => {
|
const playersWithAccess = game.users.reduce((acc, user) => {
|
||||||
const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown);
|
const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown);
|
||||||
if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
|
if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
|
||||||
|
|
@ -114,6 +117,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const nonGmPlayers = game.users.filter(x => !x.isGM);
|
const nonGmPlayers = game.users.filter(x => !x.isGM);
|
||||||
|
|
||||||
const countdownEditable = game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;
|
const countdownEditable = game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER;
|
||||||
|
|
@ -129,7 +133,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
!countdownEditable ||
|
!countdownEditable ||
|
||||||
(isLooping && (countdown.progress.current > 0 || countdown.progress.start === '0'));
|
(isLooping && (countdown.progress.current > 0 || countdown.progress.start === '0'));
|
||||||
|
|
||||||
acc[key] = {
|
const countdownData = {
|
||||||
...countdown,
|
...countdown,
|
||||||
editable: countdownEditable,
|
editable: countdownEditable,
|
||||||
noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0,
|
noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0,
|
||||||
|
|
@ -137,9 +141,21 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
||||||
loopDisabled: isLooping ? loopDisabled : null,
|
loopDisabled: isLooping ? loopDisabled : null,
|
||||||
loopTooltip: isLooping && game.i18n.localize(loopTooltip)
|
loopTooltip: isLooping && game.i18n.localize(loopTooltip)
|
||||||
};
|
};
|
||||||
|
if (countdown.type == CONFIG.DH.GENERAL.countdownBaseTypes.longterm.id){
|
||||||
|
if (this._isFocused){
|
||||||
|
acc.longTermCountdowns.push([key, countdownData]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
acc.otherCountdowns.push([key, countdownData])
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {longTermCountdowns: [], otherCountdowns: []});
|
||||||
|
|
||||||
|
// Combine: regular countdowns first, then long-term
|
||||||
|
context.countdowns = [...otherCountdowns, ...longTermCountdowns].reduce((acc, [key, countdown]) => {
|
||||||
|
acc[key]=countdown;
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue