diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9d3d7b..3bc3fa2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: id: set-release-notes-github run: | echo "- Bugfixes:" >> release_notes.txt - echo " - Primary GM: Fix bug trying to access primaryGM setting before init" >> release_notes.txt + echo " - Primary GM: Couple additional tweaks" >> release_notes.txt echo "release-notes-github<> $GITHUB_ENV cat release_notes.txt >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV diff --git a/scripts/macros/restoreBalance.js b/scripts/macros/restoreBalance.js index 036864d..33d58f0 100644 --- a/scripts/macros/restoreBalance.js +++ b/scripts/macros/restoreBalance.js @@ -1,15 +1,15 @@ -/*export async function restoreBalance({workflowData,workflowType,workflowCombat}) { +export async function restoreBalance({workflowData,workflowType,workflowCombat}) { const module = await import('../module.js'); const socket = module.socket; const helpers = await import('../helpers.js'); const workflowUuid = workflowData; const workflow = await MidiQOL.Workflow.getWorkflow(workflowUuid); - let gpsUuid = "gps_d7274115-5734-4b08-a15c-23ebf02b77f7" - let itemName = "restore balance"; - let itemProperName = "Restore Balance"; - let dialogId = "restorebalance"; if(!workflow) return; - if(workflow.item.name === itemProperName) return; + const gpsUuid = "d7274115-5734-4b08-a15c-23ebf02b77f7" + if(workflow.item.flags["gambits-premades"]?.gpsUuid === gpsUuid) return; + let itemName = "Restore Balance"; + let dialogId = gpsUuid; + let gmUser = helpers.getPrimaryGM(); // Check if attack hits if(workflowType === "attack" && workflow.token.document.disposition === workflow.attackTotal < workflow.targets.first().actor.system.attributes.ac.value) return; @@ -22,21 +22,21 @@ findValidTokens = helpers.findValidTokens({initiatingToken: workflow.token, targetedToken: null, itemName: itemName, itemType: "feature", itemChecked: null, reactionCheck: true, sightCheck: true, rangeCheck: true, rangeTotal: 60, dispositionCheck: true, dispositionCheckType: "enemy", workflowType: workflowType, workflowCombat: workflowCombat, gpsUuid: gpsUuid}); } else if(workflowType === "save") { - findValidTokens = helpers.findValidTokens({initiatingToken: workflow.token, targetedToken: null, itemName: itemName, itemType: "feature", itemChecked: null, reactionCheck: true, sightCheck: false, rangeCheck: false, rangeTotal: null, dispositionCheck: true, dispositionCheckType: "ally", workflowType: workflowType, workflowCombat: workflowCombat, gpsUuid: gpsUuid}); + findValidTokens = helpers.findValidTokens({initiatingToken: workflow.token, targetedToken: null, itemName: itemName, itemType: "feature", itemChecked: null, reactionCheck: true, sightCheck: true, rangeCheck: true, rangeTotal: 60, dispositionCheck: true, dispositionCheckType: "ally", workflowType: workflowType, workflowCombat: workflowCombat, gpsUuid: gpsUuid}); } let browserUser; for (const validTokenPrimary of findValidTokens) { - if(workflowType === "attack" && workflow.token.document.disposition === validTokenPrimary.document.disposition && workflow.advantage === true && workflow.disadvantage === false) return; + if(workflowType === "attack" && workflow.token.document.disposition === validTokenPrimary.document.disposition && workflow.advantage === true) return; if(workflowType === "attack" && workflow.token.document.disposition !== validTokenPrimary.document.disposition && workflow.advantage === false) return; - const initialTimeLeft = Number(MidiQOL.safeGetGameSetting('gambits-premades', `${itemProperName} Timeout`)); let chosenItem = validTokenPrimary.actor.items.find(i => i.flags["gambits-premades"]?.gpsUuid === gpsUuid); + let itemProperName = chosenItem?.name; const dialogTitlePrimary = `${validTokenPrimary.actor.name} | ${itemProperName}`; const dialogTitleGM = `Waiting for ${validTokenPrimary.actor.name}'s selection | ${itemProperName}`; + const initialTimeLeft = Number(MidiQOL.safeGetGameSetting('gambits-premades', `${itemProperName} Timeout`)); - browserUser = MidiQOL.playerForActor(validTokenPrimary.actor); - if (!browserUser.active) browserUser = game.users?.activeGM; + browserUser = helpers.getBrowserUser({ actorUuid: validTokenPrimary.actor.uuid }); let dialogContent; const rollDetailSetting = MidiQOL.safeGetGameSetting('midi-qol', 'ConfigSettings').hideRollDetails; @@ -100,7 +100,7 @@
-

Would you like to use your reaction to cast ${itemProperName}? ${["none", "detailsDSN", "details"].includes(rollDetailSetting) ? `An enemy successfully hit your ally with a ${workflow.attackTotal}.` : "An enemy successfully hit your ally."} Choose an ally to give advantage to below.

+

Would you like to use your reaction to cast ${itemProperName}? An enemy successfully hit your ally with a ${workflow.attackTotal}.

@@ -272,4 +272,4 @@ } } } -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/scripts/module.js b/scripts/module.js index a114279..3d3f9da 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -162,7 +162,7 @@ Hooks.once('ready', async function() { console.error("Error loading compendium data:", error); }); - if(!game.gpsSettings.primaryGM) game.settings.set("gambits-premades", "primaryGM", game.users.activeGM.id); + if(game.user.isGM && !game.settings.get("gambits-premades", "primaryGM")) game.settings.set("gambits-premades", "primaryGM", game.users.activeGM?.id); game.gps = { gmIdentifyItem, @@ -348,8 +348,7 @@ async function updateSettings(settingKey = null) { 'enableMageSlayer': 'mageSlayerEnabled', 'enableInstinctiveCharm': 'instinctiveCharmEnabled', 'enableRainOfCinders': 'rainOfCindersEnabled', - 'Enable Opportunity Attack': 'opportunityAttackEnabled', - 'primaryGM': 'primaryGM' + 'Enable Opportunity Attack': 'opportunityAttackEnabled' }; if (settingKey === null) {