diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d8aedd..c5cd553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## v0.1.1 - 18-02-2025 +* Added `/effect X` chat command + ## v0.1.0 - 18-02-2025 * Initial release diff --git a/dist/champions-now.mjs b/dist/champions-now.mjs index abc9fe1..ad72efa 100644 --- a/dist/champions-now.mjs +++ b/dist/champions-now.mjs @@ -2250,3 +2250,25 @@ Hooks.once("ready", () => { Hooks.once("renderChatLog", (app, html, _options) => { html.addClass("champions-now"); }); + +Hooks.on("chatMessage", (html, content, msg) => { + const rollMode = game.settings.get("core", "rollMode"); + + if (["gmroll", "blindroll"].includes(rollMode)) + msg["whisper"] = ChatMessage.getWhisperRecipients("GM").map(u => u.id); + + if (rollMode === "blindroll") + msg["blind"] = true; + + const regExp = /(\S+)/g; + const commands = content.match(regExp); + const command = commands[0]; + + if (command === "/effect") { + const amount = Number(commands[1]) ?? 3; + const roll = new EffectRoll(`${amount}d6`); + roll.toMessage(); + + return false; + } +}); diff --git a/src/champions-now.mjs b/src/champions-now.mjs index d93493d..a38c429 100644 --- a/src/champions-now.mjs +++ b/src/champions-now.mjs @@ -6,6 +6,7 @@ import {registerHandlebarsHelpers} from "./modules/handlebars.mjs"; import {initialConfig, registerDataModels, registerSheets, setDocumentClasses} from "./modules/config.mjs"; import {registerSettings} from "./modules/Settings.mjs"; import Utility from "./modules/utility/Utility.mjs"; +import EffectRoll from "./modules/features/EffectRoll.mjs"; Hooks.once("init", () => { game.system.links = LINKS; @@ -45,4 +46,26 @@ Hooks.once("ready", () => { Hooks.once("renderChatLog", (app, html, _options) => { html.addClass("champions-now"); +}); + +Hooks.on("chatMessage", (html, content, msg) => { + const rollMode = game.settings.get("core", "rollMode"); + + if (["gmroll", "blindroll"].includes(rollMode)) + msg["whisper"] = ChatMessage.getWhisperRecipients("GM").map(u => u.id); + + if (rollMode === "blindroll") + msg["blind"] = true; + + const regExp = /(\S+)/g; + const commands = content.match(regExp); + const command = commands[0]; + + if (command === "/effect") { + const amount = Number(commands[1]) ?? 3; + const roll = new EffectRoll(`${amount}d6`); + roll.toMessage(); + + return false; + } }); \ No newline at end of file