Skip to content

Commit

Permalink
Merge pull request #697 from pafvel/main
Browse files Browse the repository at this point in the history
Dragonbane support
  • Loading branch information
otigon authored Apr 9, 2024
2 parents 2c587c2 + 6bc7da5 commit dd66d20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/system-support/aa-dragonbane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { trafficCop } from "../router/traffic-cop.js"
import AAHandler from "../system-handlers/workflow-data.js";
import { getRequiredData } from "./getRequiredData.js";

export function systemHooks() {
Hooks.on("createChatMessage", async (msg) => {
if (msg.user.id !== game.user.id) { return };

// Extract the item id from the Roll Damage button.
// The item id is only available on successful spells casts and weapon attacks.
function extractItemId(content) {
try {
let itemId = $(content).find('.magic-roll').attr("data-spell-id");
if (!itemId) {
itemId = $(content).find('.weapon-roll').attr("data-weapon-id");
}
return itemId;
} catch (exception) {
console.log("COULD NOT GET ITEM ID")
return null;
}
}

let compiledData = await getRequiredData({
itemId: extractItemId(msg.content),
actorId: msg.speaker?.actor,
tokenId: msg.speaker?.token,
workflow: msg,
})
if (!compiledData.item) { return; }
runDragonbane(compiledData);
});
}

async function runDragonbane(input) {
const handler = await AAHandler.make(input);
trafficCop(handler);
}
1 change: 1 addition & 0 deletions src/system-support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ export * as ptu from "./aa-ptu.js";
export * as lancer from "./aa-lancer.js";
export * as anarchy from "./aa-shadowrun-anarchy.js";
export * as wrathandglory from "./aa-wrath-and-glory.js";
export * as dragonbane from "./aa-dragonbane.js";

0 comments on commit dd66d20

Please sign in to comment.