Skip to content

Commit

Permalink
Add functionality to otherwise useless chat button (rolls 1d100).
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickburk1988 committed Mar 6, 2024
1 parent 5794bb1 commit 4000afd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.2.6

- Added functionality to otherwise useless chat button (rolls 1d100).

## v1.2.5

- Added world setting for using "Me, Myself & You" identity features.
Expand Down
34 changes: 34 additions & 0 deletions module/unknown-armies.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ Hooks.once("init", async function() {
});

Hooks.on("renderDialog", (dialog, html) => {
// MAYBE Remove dialog?
let hiddenTypes = [
"identity",
"milestone"
Expand All @@ -157,4 +158,37 @@ Hooks.on("renderDialog", (dialog, html) => {
i.remove();
}
});
});

Hooks.on("renderSidebarTab", (app, html) => {
if (app.tabName === "chat") {
html.find(".chat-control-icon").on("click", async () => {
let roll = new Roll("1d100");
await roll.evaluate();
let rollResult = parseInt(roll.result);
let content = "";
content += `<div class="dice-roll">`;
content += ` <div class="dice-result">`;
content += ` <h4 class="dice-total">${rollResult}</h4>`;
content += ` <div class="dice-tooltip">`;
content += ` <section class="tooltip-part">`;
content += ` <div class="dice">`;
content += ` <header class="part-header flexrow">`;
content += ` <span class="part-formula">1d100</span>`;
content += ` <span class="part-total">${rollResult}</span>`;
content += ` </header>`;
content += ` <ol class="dice-rolls">`;
content += ` <li class="roll die d100">${rollResult}</li>`;
content += ` </ol>`;
content += ` </div>`;
content += ` </section>`;
content += ` </div>`;
content += ` </div>`;
content += `</div>`;
roll.toMessage({
content: content,
flavor: "1d100"
});
});
}
});
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "unknownarmies",
"version": "1.2.5",
"version": "1.2.6",
"title": "Unknown Armies",
"description": "An occult game about broken people conspiring to fix the world.",
"background": "systems/unknownarmies/image/system-background.webp",
Expand Down

0 comments on commit 4000afd

Please sign in to comment.