mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-08 06:56:12 +01:00
ArmorStack use as User query
This commit is contained in:
parent
7d7fb88035
commit
e23ca28418
7 changed files with 101 additions and 57 deletions
|
|
@ -1,4 +1,4 @@
|
|||
export function handleSocketEvent({ action = null, data = {} } = {}) {
|
||||
export function handleSocketEvent({ action = null, data = {} } = {}, ...args) {
|
||||
switch (action) {
|
||||
case socketEvent.GMUpdate:
|
||||
Hooks.callAll(socketEvent.GMUpdate, data);
|
||||
|
|
@ -63,21 +63,28 @@ export const registerSocketHooks = () => {
|
|||
});
|
||||
};
|
||||
|
||||
export const emitAsGM = async (eventName, callback, args) => {
|
||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||
if(!game.user.isGM) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const response = await game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||
action: socketEvent.GMUpdate,
|
||||
data: {
|
||||
action: eventName,
|
||||
update: args
|
||||
}
|
||||
});
|
||||
resolve(response);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return await game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||
action: socketEvent.GMUpdate,
|
||||
data: {
|
||||
action: eventName,
|
||||
uuid,
|
||||
update
|
||||
}
|
||||
})
|
||||
} else return callback(args);
|
||||
});
|
||||
} else return callback(update);
|
||||
}
|
||||
|
||||
export const emitAsOwner = (eventName, userId, args) => {
|
||||
if(userId === game.user.id) return;
|
||||
if(!eventName || !userId) return false;
|
||||
game.socket.emit(`system.${CONFIG.DH.id}`, {
|
||||
action: eventName,
|
||||
data: {
|
||||
userId,
|
||||
...args
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue