From 3be91000c00312b9d168d467548c602a1da02377 Mon Sep 17 00:00:00 2001 From: Gambit Date: Sat, 9 Mar 2024 13:31:39 -0500 Subject: [PATCH] 0.0.97 --- .github/workflows/main.yml | 4 +-- module.json | 2 +- scripts/macros/silveryBarbs.js | 9 ++++-- scripts/settings.js | 43 +++++++++++++++++++++++++++++ templates/homebrewSettingsMenu.html | 7 +++++ 5 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 templates/homebrewSettingsMenu.html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 924d6d6f..fd3b89f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,8 @@ jobs: - name: Set Release Notes for Github id: set-release-notes-github run: | - echo "- Bugfixes:" >> release_notes.txt - echo " - Silvery Barbs: Fix attack rolls of allies triggering silvery barbs. Updated Effect icon to use the Silvery Barbs item icon" >> release_notes.txt + echo "- Updates:" >> release_notes.txt + echo " - Silvery Barbs: Add homebrew option to disable Silvery Barbs on a nat 20 attack roll. Optimize validation checks slightly" >> release_notes.txt echo "release-notes-github<> $GITHUB_ENV cat release_notes.txt >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV diff --git a/module.json b/module.json index c39719ff..25804fdc 100644 --- a/module.json +++ b/module.json @@ -7,7 +7,7 @@ "name": "Gambit" } ], - "version": "0.0.96", + "version": "0.0.97", "compatibility": { "minimum": "11", "verified": "11", diff --git a/scripts/macros/silveryBarbs.js b/scripts/macros/silveryBarbs.js index c9a6b6f9..34ae2b56 100644 --- a/scripts/macros/silveryBarbs.js +++ b/scripts/macros/silveryBarbs.js @@ -6,13 +6,16 @@ export async function silveryBarbs({workflowData,workflowType}) { const workflowUuid = workflowData; const workflow = await MidiQOL.Workflow.getWorkflow(workflowUuid); if(!workflow) return; - console.log(workflow) if(workflow.item.name.toLowerCase() === "silvery barbs") return; if (!game.combat) return; // Check if attack hits - if((workflowType === "attack" && workflow.attackTotal < workflow.targets.first().actor.system.attributes.ac.value) || workflow.item.name === "Opportunity Attack") return; + if(workflowType === "attack" && workflow.attackTotal < workflow.targets.first().actor.system.attributes.ac.value) return; + // Check if there is a save success target + if(workflowType === "save" && workflow.saves.size === 0) return; + // Check if Opportunity Attack is initiating the workflow + if(workflow.item.name === "Opportunity Attack") return; function findSilveryBarbsTokens(token, dispositionCheck) { let validTokens = canvas.tokens.placeables.filter(t => { @@ -167,6 +170,7 @@ export async function silveryBarbs({workflowData,workflowType}) { if(workflowType === "attack") { if (workflow.token.document.disposition === validTokenPrimary.document.disposition) return; + if (game.settings.get('gambits-premades', 'disableSilveryBarbsOnNat20') === true && workflow.isCritical === true) return; const {silveryBarbsDecision, returnedTokenUuid} = await socket.executeAsUser("showSilveryBarbsDialog", browserUser.id, originTokenUuidPrimary, actorUuidPrimary, validTokenPrimary.document.uuid, dialogTitlePrimary, originTokenUuidPrimary, "attack"); if (silveryBarbsDecision === false || !silveryBarbsDecision) continue; if (silveryBarbsDecision === true) { @@ -308,7 +312,6 @@ export async function showSilveryBarbsDialog(tokenUuids, actorUuid, tokenUuid, d } let chosenSpell = actor.items.find(i => i.name.toLowerCase() === "silvery barbs"); - console.log(chosenSpell) chosenSpell.prepareData(); chosenSpell.prepareFinalAttributes(); diff --git a/scripts/settings.js b/scripts/settings.js index ac33ab89..8164650d 100644 --- a/scripts/settings.js +++ b/scripts/settings.js @@ -79,4 +79,47 @@ function registerSettings() { } } }); + + game.settings.registerMenu('gambits-premades', 'customConfig', { + name: game.i18n.localize("Configure Homebrew Options"), + label: game.i18n.localize("Configure"), + hint: game.i18n.localize("Homebrew options for the spells below"), + icon: 'fas fa-wrench', + scope: 'world', + config: true, + type: homebrewSettingsMenu, + restricted: true + }); + + game.settings.register("gambits-premades", "disableSilveryBarbsOnNat20", { + name: "disableSilveryBarbsOnNat20", + scope: "world", + config: false, + type: Boolean, + default: false, + type: Boolean + }); +} + +class homebrewSettingsMenu extends FormApplication { + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + id: "homebrewSettingsMenu", + title: "Homebrew Options", + template: "modules/gambits-premades/templates/homebrewSettingsMenu.html", + classes: ["gambits-premades", "settings-window"], + width: 500, + closeOnSubmit: true + }); + } + + getData() { + return { + disableSilveryBarbsOnNat20: game.settings.get("gambits-premades", "disableSilveryBarbsOnNat20") + }; + } + + async _updateObject(event, formData) { + await game.settings.set("gambits-premades", "disableSilveryBarbsOnNat20", formData.disableSilveryBarbsOnNat20); + } } \ No newline at end of file diff --git a/templates/homebrewSettingsMenu.html b/templates/homebrewSettingsMenu.html new file mode 100644 index 00000000..4dcb9e38 --- /dev/null +++ b/templates/homebrewSettingsMenu.html @@ -0,0 +1,7 @@ +
+
+ + +
+ +
\ No newline at end of file