Skip to content

Commit

Permalink
Check for disabled module with MidiQOL
Browse files Browse the repository at this point in the history
  • Loading branch information
Yosoy-Ed committed Jul 17, 2024
1 parent 4333d2d commit b851f02
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions scripts/cm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ import { verifyimgfolders, criticalmessage, detectroll } from './cm-functions.js

/************************************************** CHAT DICE HOOKS ***********/
// If dice so nice is not active
Hooks.on("createChatMessage", (chatMessage) => {
/*
console.log('createChatMessage:')
console.log(chatMessage)
console.log(chatMessage.isRoll)
*/
if (game.modules.get("dice-so-nice")?.active){ //If dice so nice is active but the roll is blind and ghost dice is not enabled
if(!game.settings.get("dice-so-nice", "showGhostDice") && chatMessage.blind && !game.settings.get('critic-message', 'disablemodule') && chatMessage.isRoll){
Hooks.on("createChatMessage", (chatMessage) => {

if (game.modules.get("dice-so-nice")?.active) { //If dice so nice is active but the roll is blind and ghost dice is not enabled
if (!game.settings.get("dice-so-nice", "showGhostDice") && chatMessage.blind && !game.settings.get('critic-message', 'disablemodule') && chatMessage.isRoll) {

detectroll(chatMessage);
detectroll(chatMessage);
}
}

if (!game.modules.get("dice-so-nice")?.active && !game.settings.get('critic-message', 'disablemodule') && chatMessage.isRoll ) {
if (!game.modules.get("dice-so-nice")?.active && !game.settings.get('critic-message', 'disablemodule') && chatMessage.isRoll) {

detectroll(chatMessage);
}

Expand All @@ -28,23 +24,26 @@ Hooks.on('diceSoNiceRollComplete', (data) => {

let chatMessage = game.messages.get(data);

if (game.settings.get('critic-message', 'disablemodule') || (chatMessage.blind && !game.settings.get("dice-so-nice", "showGhostDice"))) {// if the roll is blind it was registered like dice so nice is not installed and evaluated before
if (game.settings.get('critic-message', 'disablemodule') || (chatMessage.blind && !game.settings.get("dice-so-nice", "showGhostDice"))) {// if the roll is blind it was registered like dice so nice is not installed and evaluated before
return;
}
}

detectroll(chatMessage);
});

//MidiQOL Compatibility
Hooks.on('midi-qol.RollComplete', (workflow) => {

Hooks.on('midi-qol.postAttackRollComplete', (data) => {
let chatMessage = workflow.chatCard;

console.log(data);
//console.log(data.chatCard.rolls[0]);
detectroll(data.chatCard);
if (!game.settings.get('critic-message', 'disablemodule')) {

detectroll(chatMessage);
}
});
/****************************************************************************** */

/***************************** INIT SETTINGS ************************************ */
/***************************** INIT SETTINGS ************************************ */
Hooks.once('init', function () {

//Option to stop detecting Natural dices
Expand Down Expand Up @@ -245,13 +244,13 @@ Hooks.once('init', function () {
Hooks.once('ready', function () {

if (game.user.isGM) {
verifyimgfolders();
verifyimgfolders();
}
});

Hooks.on('closeSettingsConfig', function () {
if (game.user.isGM) {
verifyimgfolders();
verifyimgfolders();
}
});

Expand Down

0 comments on commit b851f02

Please sign in to comment.