Added domain registration and global features

This commit is contained in:
CPTN Cosmo 2026-04-15 15:38:23 +02:00
parent e2dd2eff07
commit 56f2281835
7 changed files with 120 additions and 1 deletions

BIN
icons/blood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/dread.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

3
icons/svg/blood.svg Normal file
View file

@ -0,0 +1,3 @@
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path d="M50 10 Q20 50 50 90 Q80 50 50 10Z" fill="#880808" />
</svg>

After

Width:  |  Height:  |  Size: 159 B

6
icons/svg/terror.svg Normal file
View file

@ -0,0 +1,6 @@
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="40" fill="#2d004d" />
<circle cx="35" cy="40" r="8" fill="white" opacity="0.6" />
<circle cx="65" cy="40" r="8" fill="white" opacity="0.6" />
<path d="M35 70 Q50 60 65 70" stroke="white" stroke-width="3" fill="none" opacity="0.6" />
</svg>

After

Width:  |  Height:  |  Size: 363 B

View file

@ -70,5 +70,6 @@
"compatibility": {}
}
]
}
},
"esmodules": ["scripts/voidborne.js"]
}

14
scripts/features.js Normal file
View file

@ -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
}

95
scripts/voidborne.js Normal file
View file

@ -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);
}
}
}