diff --git a/icons/blood.png b/icons/blood.png new file mode 100644 index 0000000..e386d27 Binary files /dev/null and b/icons/blood.png differ diff --git a/icons/dread.png b/icons/dread.png new file mode 100644 index 0000000..20e4ad3 Binary files /dev/null and b/icons/dread.png differ diff --git a/icons/svg/blood.svg b/icons/svg/blood.svg new file mode 100644 index 0000000..a6e9f5c --- /dev/null +++ b/icons/svg/blood.svg @@ -0,0 +1,3 @@ + + + diff --git a/icons/svg/terror.svg b/icons/svg/terror.svg new file mode 100644 index 0000000..292ea04 --- /dev/null +++ b/icons/svg/terror.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/module.json b/module.json index 555ea74..ae14b98 100755 --- a/module.json +++ b/module.json @@ -70,5 +70,6 @@ "compatibility": {} } ] - } + }, + "esmodules": ["scripts/voidborne.js"] } \ No newline at end of file diff --git a/scripts/features.js b/scripts/features.js new file mode 100644 index 0000000..9db81f8 --- /dev/null +++ b/scripts/features.js @@ -0,0 +1,14 @@ +/** + * Library of Void Features + * Export functions here to make them available globally under window.Void + */ + +export function ComboStrikes() { + console.log("Combo Strikes executed!"); + // Logic for Combo Strikes +} + +export function NewFunction() { + console.log("New Void Function executed!"); + // Logic for New Function +} diff --git a/scripts/voidborne.js b/scripts/voidborne.js new file mode 100644 index 0000000..8979563 --- /dev/null +++ b/scripts/voidborne.js @@ -0,0 +1,95 @@ +// Import generic features from the library file +import * as VoidFeatures from './features.js'; + +const MODULE_ID = 'daggerheart-voidborne'; + +console.log(`${MODULE_ID} | Module JS Loaded`); + +Hooks.once('init', () => { + console.log(`${MODULE_ID} | Initializing The Void (Unofficial)`); + + // Expose the Void features globally + // This allows Void.ComboStrikes(), Void.NewFunction(), etc. + window.Void = window.Void || {}; + + // Assign all exported functions from features.js to window.Void + Object.assign(window.Void, VoidFeatures); + + console.log(`${MODULE_ID} | Void features registered:`, Object.keys(VoidFeatures)); +}); + +Hooks.on('ready', async () => { + // Only run if the system is Daggerheart + if (game.system.id !== 'daggerheart') return; + + // Register Blood and Dread domains in system settings + await registerVoidDomains(); +}); + +async function registerVoidDomains() { + // Access Daggerheart Homebrew Settings + // The system stores homebrew config in a setting named 'Homebrew' (case sensitive check needed) + + // Check if the setting exists + let homebrewSettings; + try { + homebrewSettings = game.settings.get('daggerheart', 'Homebrew'); + } catch (e) { + try { + homebrewSettings = game.settings.get('daggerheart', 'homebrew'); + } catch (e2) { + console.warn(`${MODULE_ID} | Could not find Daggerheart 'Homebrew' or 'homebrew' setting.`); + return; + } + } + + if (!homebrewSettings) return; + + const domainData = { + 'blood': { + id: 'blood', + label: 'Blood', + src: `modules/${MODULE_ID}/icons/blood.png`, + description: 'The Blood domain.' + }, + 'dread': { + id: 'dread', + label: 'Dread', + src: `modules/${MODULE_ID}/icons/dread.png`, + description: 'The Dread domain.' + } + }; + + let updates = false; + // user domains are in homebrewSettings.domains + const currentDomains = { ...(homebrewSettings.domains || {}) }; + + for (const [key, data] of Object.entries(domainData)) { + if (!currentDomains[key]) { + console.log(`${MODULE_ID} | Registering missing domain: ${data.label}`); + currentDomains[key] = data; + updates = true; + } + } + + if (updates) { + // Update the setting + try { + // We need to keep the structure of homebrewSettings intact + const newSettings = { + ...homebrewSettings, + domains: currentDomains + }; + + // We need to know the Key used to set it. + let key = 'Homebrew'; + if (game.settings.settings.has('daggerheart.homebrew')) key = 'homebrew'; + + await game.settings.set('daggerheart', key, newSettings); + + ui.notifications.info(`${MODULE_ID} | Registered missing domains (Blood/Dread) in Homebrew Settings.`); + } catch (err) { + console.error(`${MODULE_ID} | Failed to update settings:`, err); + } + } +}