Feature/247 auto add yope fear clear stress (#285)

* cleanup

* test

* Step 1

* #2

* Fix Effect Action & Add Hope tumation settings to hook

* remove circular dependency

* Snuck in some localization fixes I noticed

* Remove success condition for duality roll gain

* Changed config.roll.type logic

---------

Co-authored-by: WBHarry <williambjrklund@gmail.com>
This commit is contained in:
Dapoulp 2025-07-07 01:38:39 +02:00 committed by GitHub
parent ee4a5d17a6
commit 52be430eff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 187 additions and 160 deletions

View file

@ -39,20 +39,16 @@ export const registerSocketHooks = () => {
}
break;
case GMUpdateEvent.UpdateSetting:
if (game.user.isGM) {
await game.settings.set(CONFIG.DH.id, data.uuid, data.update);
}
await game.settings.set(CONFIG.DH.id, data.uuid, data.update);
break;
case GMUpdateEvent.UpdateFear:
if (game.user.isGM) {
await game.settings.set(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Resources.Fear,
Math.max(Math.min(data.update, 6), 0)
);
Hooks.callAll(socketEvent.DhpFearUpdate);
await game.socket.emit(`system.${CONFIG.DH.id}`, { action: socketEvent.DhpFearUpdate });
}
await game.settings.set(
CONFIG.DH.id,
CONFIG.DH.SETTINGS.gameSettings.Resources.Fear,
Math.max(0, Math.min(game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).maxFear, data.update))
);
/* Hooks.callAll(socketEvent.DhpFearUpdate);
await game.socket.emit(`system.${CONFIG.DH.id}`, { action: socketEvent.DhpFearUpdate }); */
break;
}
@ -66,3 +62,22 @@ export const registerSocketHooks = () => {
}
});
};
export const emitAsGM = async (eventName, callback, args) => {
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);
}
})
} else return callback(args);
}