debug: enable and add console logging for Dice So Nice critical hit detection and roll processing.

This commit is contained in:
CPTN Cosmo 2026-02-10 03:32:26 +01:00
parent fe9233cae2
commit e57d889a21
No known key found for this signature in database

View file

@ -183,35 +183,38 @@ Hooks.on('renderChatMessage', (message, html, data) => {
// Hook into DiceSoNice to trigger effects
// Hook into DiceSoNice to trigger effects
Hooks.on('diceSoNiceRollStart', (messageId, context) => {
// console.log('DSN Hook Fired', messageId, context);
console.log('DSN Hook Fired', messageId, context);
const roll = context.roll;
if (!roll) return;
if (isCriticalHit(roll)) {
// console.log('DSN: Critical Hit Detected');
console.log('DSN: Critical Hit Detected');
const effect = game.settings.get('dh-immersive-crits', 'dsnCritEffect');
// console.log('DSN Effect:', effect);
console.log('DSN Effect:', effect);
if (effect && effect !== 'none') {
// Check if roll.dice exists and has elements
if (roll.dice && roll.dice.length > 0) {
roll.dice.forEach(die => {
if (!die.options) die.options = {};
die.options.specialEffect = effect === 'default' ? 'Stars' : capitalize(effect);
// console.log('Applied effect to die:', die);
console.log('Applied effect to die:', die);
});
} else {
// Determine if we need to iterate terms for Duality Rolls
// console.log('No roll.dice found. Checking terms:', roll.terms);
console.log('No roll.dice found. Checking terms:', roll.terms);
if (roll.terms) {
roll.terms.forEach(term => {
if (term.faces) { // It's a die
if (!term.options) term.options = {};
term.options.specialEffect = effect === 'default' ? 'Stars' : capitalize(effect);
console.log('Applied effect to term:', term);
}
});
}
}
}
} else {
console.log('DSN: Not a Critical Hit', roll.constructor.name, roll);
}
});