Skip to content

Commit

Permalink
0.0.97
Browse files Browse the repository at this point in the history
  • Loading branch information
gambit07 committed Mar 9, 2024
1 parent 37c663d commit 3be9100
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF" >> $GITHUB_ENV
cat release_notes.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Gambit"
}
],
"version": "0.0.96",
"version": "0.0.97",
"compatibility": {
"minimum": "11",
"verified": "11",
Expand Down
9 changes: 6 additions & 3 deletions scripts/macros/silveryBarbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
43 changes: 43 additions & 0 deletions scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 7 additions & 0 deletions templates/homebrewSettingsMenu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form>
<div class="form-group">
<label for="disableSilveryBarbsOnNat20">Silvery Barbs: Disable on a Nat 20 Attack Roll</label>
<input type="checkbox" id="disableSilveryBarbsOnNat20" name="disableSilveryBarbsOnNat20" data-dtype="Boolean" {{checked disableSilveryBarbsOnNat20}}>
</div>
<button type="submit">Save Changes</button>
</form>

0 comments on commit 3be9100

Please sign in to comment.