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