From f57096564274b8033a3a6f87bedd0d4540f431fe Mon Sep 17 00:00:00 2001 From: alzer <> Date: Wed, 12 Aug 2026 10:22:06 +0200 Subject: [PATCH] =?UTF-8?q?gasthaus-Chatbefehl=20von=20wh4-lang-de=20?= =?UTF-8?q?=C3=BCbernommen=20(geh=C3=B6rt=20zum=20gerichte-gasthaeuser-Pac?= =?UTF-8?q?k,=20das=20hierher=20umgezogen=20ist)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module.json | 3 +++ modules/gasthaus-command.js | 46 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 modules/gasthaus-command.js diff --git a/module.json b/module.json index 46a211c..abb6670 100644 --- a/module.json +++ b/module.json @@ -15,6 +15,9 @@ "flags": {} } ], + "esmodules": [ + "modules/gasthaus-command.js" + ], "packs": [ { "name": "sternzeichen", diff --git a/modules/gasthaus-command.js b/modules/gasthaus-command.js new file mode 100644 index 0000000..7c796a3 --- /dev/null +++ b/modules/gasthaus-command.js @@ -0,0 +1,46 @@ +/************************************************************************************/ +/* Manages /gasthaus command - rolls on a RollTable from the gerichte-gasthaeuser pack */ +/* (moved here from wh4-lang-de/modules/addon-register.js together with the pack) */ +const _manage_inn_roll = async (content, msg) => { + // Split input into arguments + let command = content.split(" ").map(function (item) { + return item.trim(); + }) + + console.log("COMMANDES", command); + if (command[0] == "/gasthaus" && command[1]) { + msg["type"] = 0; + msg["rollMode"] = "gmroll"; + var compendium = game.packs.get('risikogruppe.gerichte-gasthaeuser') + const pack = game.packs.get(compendium); + let rollList = await compendium.getDocuments() + //console.log("AUBERGE", rollList) + for (var i = 0; i < rollList.length; i++) { + var rollTab = rollList[i]; + console.log("Got compendium...", rollList, rollTab.name); + if (rollTab.name.toLowerCase().includes(command[1].toLowerCase())) { + let my_rollTable; + await compendium.getDocument(rollTab._id).then(mytab => my_rollTable = mytab); + my_rollTable.draw({ rollMode: "gmroll" }); + return false; + } + } + } + if (content.includes("/gasthaus")) { + msg["type"] = 0; + msg["rollMode"] = "gmroll"; + msg["content"] = "Syntax : /gasthaus KEYWORD, mit KEYWORD unter:
BasisGetraenke, StarkeGetraenke, Desserts, AllgemeineGerichte, ExzellenteGerichte, MaritimeGerichte, MittelmaessigeGerichte, Qualitaetsgerichte, Flussgerichte. Verknüpfungen sind mit einem Teil des Namens möglich: Basis (entspricht BasisGetraenke) oder /gasthaus Mari (entspricht MaritimeGerichte) usw." + ChatMessage.create(msg); + return false; + } +} + +/************************************************************************************/ +/* Hook for specific command */ +Hooks.on("chatMessage", (html, content, msg) => { + + if (content.toLowerCase().includes('gasthaus')) { + _manage_inn_roll(content, msg); + return false; + } +});