Merge pull request #65 from Eldritch-Oliver/bug/alert-cryptic-events-globally
Make the Cryptic Event notifications appear for all active players
This commit is contained in:
commit
1c7308e188
4 changed files with 66 additions and 1 deletions
|
|
@ -228,6 +228,13 @@ export class DelveDiceHUD extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
localizer(`RipCrypt.notifs.info.cryptic-event-alert`),
|
localizer(`RipCrypt.notifs.info.cryptic-event-alert`),
|
||||||
{ console: false },
|
{ console: false },
|
||||||
);
|
);
|
||||||
|
game.socket.emit(`system.ripcrypt`, {
|
||||||
|
event: `notify`,
|
||||||
|
payload: {
|
||||||
|
message: `RipCrypt.notifs.info.cryptic-event-alert`,
|
||||||
|
type: `info`,
|
||||||
|
},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if ([`both`, `pause`].includes(alertType) && game.user.isGM) {
|
if ([`both`, `pause`].includes(alertType) && game.user.isGM) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ Hooks.once(`ready`, () => {
|
||||||
|
|
||||||
if (game.settings.get(`ripcrypt`, `devMode`)) {
|
if (game.settings.get(`ripcrypt`, `devMode`)) {
|
||||||
ui.sidebar.expand();
|
ui.sidebar.expand();
|
||||||
if (game.paused) { game.togglePause() };
|
if (game.paused) { game.togglePause(false, { broadcast: true }) };
|
||||||
};
|
};
|
||||||
|
|
||||||
ui.delveDice.render({ force: true });
|
ui.delveDice.render({ force: true });
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { localizer } from "../utils/Localizer.mjs";
|
import { localizer } from "../utils/Localizer.mjs";
|
||||||
import { Logger } from "../utils/Logger.mjs";
|
import { Logger } from "../utils/Logger.mjs";
|
||||||
|
import { notify } from "./notify.mjs";
|
||||||
import { updateSands } from "./updateSands.mjs";
|
import { updateSands } from "./updateSands.mjs";
|
||||||
|
|
||||||
const events = {
|
const events = {
|
||||||
|
notify,
|
||||||
updateSands,
|
updateSands,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
56
module/sockets/notify.mjs
Normal file
56
module/sockets/notify.mjs
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { localizer } from "../utils/Localizer.mjs";
|
||||||
|
|
||||||
|
export function notify(payload) {
|
||||||
|
// #region Payload Validity
|
||||||
|
const {
|
||||||
|
message,
|
||||||
|
users = [],
|
||||||
|
type = `info`,
|
||||||
|
permanent = false,
|
||||||
|
} = payload;
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
ui.notifications.error(localizer(
|
||||||
|
`RipCrypt.notifs.error.malformed-socket-payload`,
|
||||||
|
{
|
||||||
|
event: `notify`,
|
||||||
|
details: `A message must be provided`,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (users && !Array.isArray(users)) {
|
||||||
|
ui.notifications.error(localizer(
|
||||||
|
`RipCrypt.notifs.error.malformed-socket-payload`,
|
||||||
|
{
|
||||||
|
event: `notify`,
|
||||||
|
details: `"users" must be an array of user IDs`,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (![`info`, `error`, `success`].includes(type)) {
|
||||||
|
ui.notifications.error(localizer(
|
||||||
|
`RipCrypt.notifs.error.malformed-socket-payload`,
|
||||||
|
{
|
||||||
|
event: `notify`,
|
||||||
|
details: `An invalid notification type was provided.`,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// #endregion Payload Validity
|
||||||
|
|
||||||
|
// Act
|
||||||
|
if (users.length === 0 || users.includes(game.user.id)) {
|
||||||
|
ui.notifications[type]?.(
|
||||||
|
localizer(message),
|
||||||
|
{
|
||||||
|
console: false,
|
||||||
|
permanent,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue