diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dd81b1ee..8afc9bda 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,10 @@ jobs: - name: Set Release Notes for Github id: set-release-notes-github run: | + echo "- Updates:" >> release_notes.txt + echo " - Silvery Barbs: Now compatible with the Counterspell automation, Silvery Barbs will be cancelled if counterspelled." >> release_notes.txt echo "- Bugfixes:" >> release_notes.txt - echo " - Silvery Barbs: Fix for attack silvery barbs not calling the correct token doc" >> release_notes.txt + echo " - Silvery Barbs: Fix advantage targets not displaying if only one target was present." >> 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 02bac9db..6d9e6c41 100644 --- a/module.json +++ b/module.json @@ -7,7 +7,7 @@ "name": "Gambit" } ], - "version": "0.0.92", + "version": "0.0.93", "compatibility": { "minimum": "11", "verified": "11", diff --git a/scripts/macros/silveryBarbs.js b/scripts/macros/silveryBarbs.js index 5967aa41..46261e00 100644 --- a/scripts/macros/silveryBarbs.js +++ b/scripts/macros/silveryBarbs.js @@ -166,51 +166,50 @@ export async function silveryBarbs({workflowData,workflowType}) { 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) { - - let rerollAddition = workflow.attackRoll.total - workflow.attackRoll.dice[0].total - let targetAC = workflow.hitTargets.first().actor.system.attributes.ac.value; - const saveSetting = workflow.options.noOnUseMacro; - workflow.options.noOnUseMacro = true; - await workflow.setAttackRoll(await new Roll(`1d20 + ${rerollAddition}`).roll({async: true})); - workflow.options.noOnUseMacro = saveSetting; - - if(workflow.attackTotal < targetAC) { - let chatList = []; - - chatList = `The creature was silvery barbed, and failed their attack. `; - - let msgHistory = []; - game.messages.reduce((list, message) => { - if (message.flags["midi-qol"]?.itemId === spellData._id && message.speaker.token === validTokenPrimary.id) msgHistory.push(message.id); - }, msgHistory); - let itemCard = msgHistory[msgHistory.length - 1]; - let chatMessage = await game.messages.get(itemCard); - let content = await duplicate(chatMessage.content); - let insertPosition = content.indexOf('
'); - if (insertPosition !== -1) { - content = content.slice(0, insertPosition) + chatList + content.slice(insertPosition); + let rerollAddition = workflow.attackRoll.total - workflow.attackRoll.dice[0].total + let targetAC = workflow.hitTargets.first().actor.system.attributes.ac.value; + const saveSetting = workflow.options.noOnUseMacro; + workflow.options.noOnUseMacro = true; + await workflow.setAttackRoll(await new Roll(`1d20 + ${rerollAddition}`).roll({async: true})); + workflow.options.noOnUseMacro = saveSetting; + + if(workflow.attackTotal < targetAC) { + let chatList = []; + + chatList = `The creature was silvery barbed, and failed their attack. `; + + let msgHistory = []; + game.messages.reduce((list, message) => { + if (message.flags["midi-qol"]?.itemId === spellData._id && message.speaker.token === validTokenPrimary.id) msgHistory.push(message.id); + }, msgHistory); + let itemCard = msgHistory[msgHistory.length - 1]; + let chatMessage = await game.messages.get(itemCard); + let content = await duplicate(chatMessage.content); + let insertPosition = content.indexOf('
'); + if (insertPosition !== -1) { + content = content.slice(0, insertPosition) + chatList + content.slice(insertPosition); + } + await chatMessage.update({ content: content }); } - await chatMessage.update({ content: content }); - } - - else { - let chatList = []; - chatList = `The creature was silvery barbed, but were still able to hit their target. `; - - let msgHistory = []; - game.messages.reduce((list, message) => { - if (message.flags["midi-qol"]?.itemId === spellData._id && message.speaker.token === validTokenPrimary.id) msgHistory.push(message.id); - }, msgHistory); - let itemCard = msgHistory[msgHistory.length - 1]; - let chatMessage = await game.messages.get(itemCard); - let content = await duplicate(chatMessage.content); - let insertPosition = content.indexOf('
'); - if (insertPosition !== -1) { - content = content.slice(0, insertPosition) + chatList + content.slice(insertPosition); + else { + let chatList = []; + + chatList = `The creature was silvery barbed, but were still able to hit their target. `; + + let msgHistory = []; + game.messages.reduce((list, message) => { + if (message.flags["midi-qol"]?.itemId === spellData._id && message.speaker.token === validTokenPrimary.id) msgHistory.push(message.id); + }, msgHistory); + let itemCard = msgHistory[msgHistory.length - 1]; + let chatMessage = await game.messages.get(itemCard); + let content = await duplicate(chatMessage.content); + let insertPosition = content.indexOf('
'); + if (insertPosition !== -1) { + content = content.slice(0, insertPosition) + chatList + content.slice(insertPosition); + } + await chatMessage.update({ content: content }); } - await chatMessage.update({ content: content }); - } } } } @@ -234,7 +233,7 @@ export async function showSilveryBarbsDialog(tokenUuids, actorUuid, tokenUuid, d

Choose who is advantaged:

- ${validFriendlies.length > 1 ? + ${validFriendlies.length >= 1 ? `` : '

No valid friendlies in range.

' @@ -270,7 +269,7 @@ export async function showSilveryBarbsDialog(tokenUuids, actorUuid, tokenUuid, d

Choose who is advantaged:

- ${validFriendlies.length > 1 ? + ${validFriendlies.length >= 1 ? `` : '

No valid friendlies in range.

' @@ -318,9 +317,6 @@ export async function showSilveryBarbsDialog(tokenUuids, actorUuid, tokenUuid, d }; const itemRoll = await MidiQOL.completeItemUse(chosenSpell, {}, options); - - let silveryBarbsDecision = true; - let returnedTokenUuid = originToken.document.uuid; const hasEffectApplied = await game.dfreds.effectInterface.hasEffectApplied('Reaction', uuid); @@ -328,6 +324,11 @@ export async function showSilveryBarbsDialog(tokenUuids, actorUuid, tokenUuid, d game.dfreds.effectInterface.addEffect({ effectName: 'Reaction', uuid }); } + if(itemRoll.aborted === true) return resolve({ silveryBarbsDecision: false, returnedTokenUuid: null }); + + let silveryBarbsDecision = true; + let returnedTokenUuid = originToken.document.uuid; + let effectData = [ { "icon": "icons/magic/control/control-influence-puppet.webp", diff --git a/scripts/settings.js b/scripts/settings.js index 7d6c5b69..ac33ab89 100644 --- a/scripts/settings.js +++ b/scripts/settings.js @@ -64,7 +64,7 @@ function registerSettings() { game.settings.register('gambits-premades', 'Silvery Barbs Timeout', { name: "Silvery Barbs Timeout", - hint: "Enter custom number (in seconds). Default timeout value is 15 seconds.", + hint: "Enter custom number (in seconds). Default timeout value is 30 seconds.", scope: 'world', config: true, type: String,