feat: Update Dice So Nice critical hit effect choices and simplify their application logic by using direct class names and removing debug logs.

This commit is contained in:
CPTN Cosmo 2026-02-10 04:02:33 +01:00
parent 6c9a219ca0
commit 5c3fd21ba6
No known key found for this signature in database

View file

@ -35,25 +35,18 @@ Hooks.once('init', () => {
type: String,
choices: {
"none": "None",
"default": "Default",
"fire": "Fire",
"ice": "Ice",
"force": "Force",
"lightning": "Lightning",
"magic": "Magic",
"stars": "Stars",
"thunder": "Thunder"
"WhiteGlow": "White Glow",
"Darkness": "Darkness",
"GlassImpact": "Glass Impact",
"Confetti": "Confetti",
"DoubleSpirals": "Double Spirals",
"Blaze": "Blaze",
"MagicVortex": "Magic Vortex"
},
default: 'default'
default: 'Blaze'
});
});
// Check if DSN is ready and log effects
Hooks.once('diceSoNiceReady', (dice3d) => {
console.log('DSN Ready. Helper:', dice3d);
const sfxModes = dice3d.getSFXModes();
console.log('DSN SFX Modes:', sfxModes);
});
});
// Hook to handle conditional settings in the UI
Hooks.on('renderSettingsConfig', (app, html, data) => {
@ -208,29 +201,20 @@ Hooks.on('renderChatMessageHTML', (message, html, data) => {
// Hook into DiceSoNice to trigger effects
Hooks.on('diceSoNiceRollStart', (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');
const effect = game.settings.get('dh-immersive-crits', 'dsnCritEffect');
console.log('DSN Effect Setting:', effect);
if (effect && effect !== 'none') {
const effectName = effect === 'default' ? 'Stars' : capitalize(effect);
console.log('DSN Applying Effect Name:', effectName);
// Function to apply effect to a die/term
const applyEffect = (term) => {
if (!term.options) term.options = {};
// Try both id (for presets) and specialEffect (for classes) to be safe,
// based on different DSN versions/styles.
// 'Stars', 'Fire', etc are likely registered system effects.
// 'effect' key from settings is now the direct Class Name (PascalCase)
term.options.sfx = {
specialEffect: effectName
specialEffect: effect
};
console.log('Applied sfx to term:', term, term.options.sfx);
};
// Check if roll.dice exists and has elements
@ -238,7 +222,6 @@ Hooks.on('diceSoNiceRollStart', (messageId, context) => {
roll.dice.forEach(die => applyEffect(die));
} else {
// Determine if we need to iterate terms for Duality Rolls
console.log('No roll.dice found. Checking terms:', roll.terms);
if (roll.terms) {
roll.terms.forEach(term => {
if (term.faces) { // It's a die
@ -248,8 +231,6 @@ Hooks.on('diceSoNiceRollStart', (messageId, context) => {
}
}
}
} else {
console.log('DSN: Not a Critical Hit');
}
});