Restructured all the files

This commit is contained in:
WBHarry 2025-07-04 17:54:18 +02:00
parent 099a4576da
commit ba3157a2fc
180 changed files with 722 additions and 1730 deletions

View file

@ -1,68 +0,0 @@
export function handleSocketEvent({ action = null, data = {} } = {}) {
switch (action) {
case socketEvent.GMUpdate:
Hooks.callAll(socketEvent.GMUpdate, data);
break;
case socketEvent.DhpFearUpdate:
Hooks.callAll(socketEvent.DhpFearUpdate);
break;
case socketEvent.Refresh:
Hooks.call(socketEvent.Refresh, data);
break;
}
}
export const socketEvent = {
GMUpdate: 'DhGMUpdate',
Refresh: 'DhRefresh',
DhpFearUpdate: 'DhFearUpdate'
};
export const GMUpdateEvent = {
UpdateDocument: 'DhGMUpdateDocument',
UpdateSetting: 'DhGMUpdateSetting',
UpdateFear: 'DhGMUpdateFear'
};
export const RefreshType = {
Countdown: 'DhCoundownRefresh'
};
export const registerSocketHooks = () => {
Hooks.on(socketEvent.GMUpdate, async data => {
if (game.user.isGM) {
const document = data.uuid ? await fromUuid(data.uuid) : null;
switch (data.action) {
case GMUpdateEvent.UpdateDocument:
if (document && data.update) {
await document.update(data.update);
}
break;
case GMUpdateEvent.UpdateSetting:
if (game.user.isGM) {
await game.settings.set(SYSTEM.id, data.uuid, data.update);
}
break;
case GMUpdateEvent.UpdateFear:
if (game.user.isGM) {
await game.settings.set(
SYSTEM.id,
SYSTEM.SETTINGS.gameSettings.Resources.Fear,
Math.max(Math.min(data.update, 6), 0)
);
Hooks.callAll(socketEvent.DhpFearUpdate);
await game.socket.emit(`system.${SYSTEM.id}`, { action: socketEvent.DhpFearUpdate });
}
break;
}
if (data.refresh) {
await game.socket.emit(`system.${SYSTEM.id}`, {
action: socketEvent.Refresh,
data: data.refresh
});
Hooks.call(socketEvent.Refresh, data.refresh);
}
}
});
};

View file

@ -1,4 +1,4 @@
import { diceTypes, getDiceSoNicePresets, range } from '../config/generalConfig.mjs';
import { diceTypes, getDiceSoNicePresets, range } from '../applications/config/generalConfig.mjs';
import Tagify from '@yaireo/tagify';
export const loadCompendiumOptions = async compendiums => {
@ -226,7 +226,7 @@ export const getDeleteKeys = (property, innerProperty, innerPropertyDefaultValue
// Fix on Foundry native formula replacement for DH
const nativeReplaceFormulaData = Roll.replaceFormulaData;
Roll.replaceFormulaData = function (formula, data = {}, { missing, warn = false } = {}) {
const terms = Object.keys(SYSTEM.GENERAL.multiplierTypes).map(type => {
const terms = Object.keys(CONFIG.DH.GENERAL.multiplierTypes).map(type => {
return { term: type, default: 1 };
});
formula = terms.reduce((a, c) => a.replaceAll(`@${c.term}`, data[c.term] ?? c.default), formula);