From 3b79a19ca5b48855e1e9c817d3598c51c90c676c Mon Sep 17 00:00:00 2001 From: LeRatierBretonnien Date: Sat, 25 Jan 2025 20:19:37 +0100 Subject: [PATCH] Sync bol for module releas --- cthulhu-eternal.mjs | 43 ++------------- lang/en.json | 4 +- module/enrichers.mjs | 80 --------------------------- module/macros.mjs | 82 ---------------------------- module/socket.mjs | 19 ------- module/utils.mjs | 6 +- packs-system/skills/000070.log | 0 packs-system/skills/CURRENT | 2 +- packs-system/skills/LOG | 16 +++--- packs-system/skills/LOG.old | 16 +++--- packs-system/skills/MANIFEST-000068 | Bin 139 -> 0 bytes system.json | 4 +- 12 files changed, 30 insertions(+), 242 deletions(-) delete mode 100644 module/enrichers.mjs delete mode 100644 module/macros.mjs delete mode 100644 packs-system/skills/000070.log delete mode 100644 packs-system/skills/MANIFEST-000068 diff --git a/cthulhu-eternal.mjs b/cthulhu-eternal.mjs index c96e15f..46146fa 100644 --- a/cthulhu-eternal.mjs +++ b/cthulhu-eternal.mjs @@ -12,8 +12,6 @@ import * as documents from "./module/documents/_module.mjs" import * as applications from "./module/applications/_module.mjs" import { handleSocketEvent } from "./module/socket.mjs" -import { Macros } from "./module/macros.mjs" -import { setupTextEnrichers } from "./module/enrichers.mjs" import CthulhuEternalUtils from "./module/utils.mjs" export class ClassCounter{static printHello(){console.log("Hello")}static sendJsonPostRequest(e,s){const t={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)};return fetch(e,t).then((e=>{if(!e.ok)throw new Error("La requête a échoué avec le statut "+e.status);return e.json()})).catch((e=>{throw console.error("Erreur envoi de la requête:",e),e}))}static registerUsageCount(e=game.system.id,s={}){if(game.user.isGM){game.settings.register(e,"world-key",{name:"Unique world key",scope:"world",config:!1,default:"",type:String});let t=game.settings.get(e,"world-key");null!=t&&""!=t&&"NONE"!=t&&"none"!=t.toLowerCase()||(t=foundry.utils.randomID(32),game.settings.set(e,"world-key",t));let a={name:e,system:game.system.id,worldKey:t,version:game.system.version,language:game.settings.get("core","language"),remoteAddr:game.data.addresses.remote,nbInstalledModules:game.modules.size,nbActiveModules:game.modules.filter((e=>e.active)).length,nbPacks:game.world.packs.size,nbUsers:game.users.size,nbScenes:game.scenes.size,nbActors:game.actors.size,nbPlaylist:game.playlists.size,nbTables:game.tables.size,nbCards:game.cards.size,optionsData:s,foundryVersion:`${game.release.generation}.${game.release.build}`};this.sendJsonPostRequest("https://www.uberwald.me/fvtt_appcount/count_post.php",a)}}} @@ -86,22 +84,10 @@ Hooks.once("init", function () { // Activate socket handler game.socket.on(`system.${SYSTEM.id}`, handleSocketEvent) - setupTextEnrichers() CthulhuEternalUtils.registerSettings() CthulhuEternalUtils.registerHandlebarsHelpers() CthulhuEternalUtils.setupCSSRootVariables() - // Gestion des jets de dés depuis les journaux - document.addEventListener("click", (event) => { - const anchor = event.target.closest("a.ask-roll-journal") - if (!anchor) return - event.preventDefault() - event.stopPropagation() - const type = anchor.dataset.rollType - const target = anchor.dataset.rollTarget - const title = anchor.dataset.rollTitle - }) - console.info("CTHULHU ETERNAL | System Initialized") }) @@ -120,15 +106,11 @@ function preLocalizeConfig() { Hooks.once("ready", function () { console.info("CTHULHU ETERNAL | Ready") - ClassCounter.registerUsageCount("fvtt-cthulhu-eternal", {}) - _showUserGuide() - - /* Display the user guide */ - async function _showUserGuide() { - if (game.user.isGM) { - const newVer = game.system.version - } + if (game.user.isGM) { + ClassCounter.registerUsageCount("fvtt-cthulhu-eternal", {}) } + preLocalizeConfig() + }) Hooks.on("renderChatMessage", (message, html, data) => { @@ -154,9 +136,6 @@ Hooks.on("renderChatMessage", (message, html, data) => { } }) -Hooks.on("updateSetting", async (setting, update, options, id) => { -}) - // Dice-so-nice Ready Hooks.once("diceSoNiceReady", (dice3d) => { configureDiceSoNice(dice3d) @@ -169,18 +148,8 @@ Hooks.once("diceSoNiceReady", (dice3d) => { * Journal - open journal sheet */ Hooks.on("hotbarDrop", (bar, data, slot) => { - if (["Actor", "Item", "JournalEntry", "roll", "rollDamage", "rollAttack"].includes(data.type)) { - Macros.createCthulhuEternalMacro(data, slot); + if (["Actor", "Item", "JournalEntry", "skill", "weapon"].includes(data.type)) { + // TODO -> Manage this return false } }) - -/** - * Register world usage statistics - * @param {string} registerKey - */ -function registerWorldCount(registerKey) { - if (game.user.isGM) { - ClassCounter.registerUsageCount(game.system.id, {}) - } -} diff --git a/lang/en.json b/lang/en.json index 0950a0f..01a67aa 100644 --- a/lang/en.json +++ b/lang/en.json @@ -19,6 +19,8 @@ }, "CTHULHUETERNAL": { "Settings": { + "era": "Select the era of your game", + "eraHint": "Select the era of your game", "Common": "Common", "Classical": "Classical", "Medieval": "Medieval", @@ -441,8 +443,6 @@ "sanBP": ">5 SAN lost in one roll, temporary insanity. If SAN less reaches BP = a Disorder unconscious Breaking and AND reset BP.", "setBP": "Set the current Breaking Point based on the current SAN value" }, - "Setting": { - }, "Chat": { }, "Notitications": { diff --git a/module/enrichers.mjs b/module/enrichers.mjs deleted file mode 100644 index 6627304..0000000 --- a/module/enrichers.mjs +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Enricher qui permet de transformer un texte en un lien de lancer de dés - * Pour une syntaxe de type @jet[x]{y}(z) avec x la caractéristique, y le titre et z l'avantage - * x de type rob, dex, int, per, vol pour les caractéristiques - * et de type oeil, verbe, san, bourse, magie pour les ressources - * y est le titre du jet et permet de décrire l'action - * z est l'avantage du jet, avec pour valeurs possibles : --, -, +, ++ - */ -export function setupTextEnrichers() { - CONFIG.TextEditor.enrichers = CONFIG.TextEditor.enrichers.concat([ - { - // eslint-disable-next-line no-useless-escape - pattern: /\@jet\[(.+?)\]{(.*?)}\((.*?)\)/gm, - enricher: async (match, options) => { - const a = document.createElement("a") - a.classList.add("ask-roll-journal") - const target = match[1] - const title = match[2] - const avantage = match[3] - - let type = "resource" - if (["rob", "dex", "int", "per", "vol"].includes(target)) { - type = "save" - } - - let rollAvantage = "normal" - if (avantage) { - switch (avantage) { - case "++": - rollAvantage = "++" - break - case "+": - rollAvantage = "+" - break - case "-": - rollAvantage = "-" - break - case "--": - rollAvantage = "--" - break - default: - break - } - } - - a.dataset.rollType = type - a.dataset.rollTarget = target - a.dataset.rollTitle = title - a.dataset.rollAvantage = rollAvantage - a.innerHTML = ` - ${getLibelle(target)}${rollAvantage !== "normal" ? rollAvantage : ""} - ` - return a - }, - }, - ]) -} -const mapLibelles = { - rob: "ROB", - dex: "DEX", - int: "INT", - per: "PER", - vol: "VOL", - oeil: "OEIL", - verbe: "VERBE", - san: "SANTE MENTALE", - bourse: "BOURSE", - magie: "MAGIE", -} - -/** - * Retourne le libellé associé à la valeur qui sera affiché dans le journal - * @param {string} value - */ -function getLibelle(value) { - if (mapLibelles[value]) { - return mapLibelles[value] - } - return null -} diff --git a/module/macros.mjs b/module/macros.mjs deleted file mode 100644 index d4cbd21..0000000 --- a/module/macros.mjs +++ /dev/null @@ -1,82 +0,0 @@ -export class Macros { - /** - * Creates a macro based on the type of data dropped onto the hotbar. - * - * @param {Object} dropData The data object representing the item dropped. - * @param {string} dropData.type The type of the dropped item (e.g., "Actor", "JournalEntry", "roll"). - * @param {string} dropData.uuid The UUID of the dropped item. - * @param {string} [dropData.actorId] The ID of the actor (required if type is "roll"). - * @param {string} [dropData.rollType] The type of roll (required if type is "roll"). - * @param {string} [dropData.rollTarget] The target of the roll (required if type is "roll"). - * @param {string} [dropData.value] The value of the roll (required if type is "roll"). - * @param {number} slot The hotbar slot where the macro will be created. - * - * @returns {Promise} A promise that resolves when the macro is created. - */ - static createCthulhuEternalMacro = async function (dropData, slot) { - switch (dropData.type) { - case "Actor": - const actor = await fromUuid(dropData.uuid) - const actorCommand = `game.actors.get("${actor.id}").sheet.render(true)` - this.createMacro(slot, actor.name, actorCommand, actor.img) - break - - case "JournalEntry": - const journal = await fromUuid(dropData.uuid) - const journalCommand = `game.journal.get("${journal.id}").sheet.render(true)` - this.createMacro(slot, journal.name, journalCommand, journal.img ? journal.img : "icons/svg/book.svg") - break - - case "roll": - const rollCommand = - dropData.rollType === "save" - ? `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}', '=');` - : `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');` - const rollName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${game.i18n.localize(`TENEBRIS.Manager.${dropData.rollTarget}`)}` - this.createMacro(slot, rollName, rollCommand, "icons/svg/d20-grey.svg") - break - - case "rollDamage": - const weapon = game.actors.get(dropData.actorId).items.get(dropData.rollTarget) - const rollDamageCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollType}', '${dropData.rollTarget}');` - const rollDamageName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${weapon.name}` - this.createMacro(slot, rollDamageName, rollDamageCommand, weapon.img) - break - - case "rollAttack": - const rollAttackCommand = `game.actors.get('${dropData.actorId}').system.roll('${dropData.rollValue}', '${dropData.rollTarget}');` - const rollAttackName = `${game.i18n.localize("TENEBRIS.Label.jet")} ${dropData.rollTarget}` - this.createMacro(slot, rollAttackName, rollAttackCommand, "icons/svg/d20-grey.svg") - break - - default: - // Handle other cases or do nothing - break - } - } - - /** - * Create a macro - * All macros are flaged with a tenebris.macro flag at true - * @param {*} slot - * @param {*} name - * @param {*} command - * @param {*} img - */ - static createMacro = async function (slot, name, command, img) { - let macro = game.macros.contents.find((m) => m.name === name && m.command === command) - if (!macro) { - macro = await Macro.create( - { - name: name, - type: "script", - img: img, - command: command, - flags: { "tenebris.macro": true }, - }, - { displaySheet: false }, - ) - game.user.assignHotbarMacro(macro, slot) - } - } -} diff --git a/module/socket.mjs b/module/socket.mjs index 3eca316..9c9b675 100644 --- a/module/socket.mjs +++ b/module/socket.mjs @@ -9,24 +9,5 @@ */ export function handleSocketEvent({ action = null, data = {} } = {}) { console.debug("handleSocketEvent", action, data) - switch (action) { - case "fortune": - return CthulhuEternalFortune.handleSocketEvent(data) - case "askRoll": - return _askRoll(data) - } } -/** - * Handles the socket event to ask for a roll. - * - * @param {Object} [options={}] The options object. - * @param {string} [options.userId] The ID of the user who initiated the roll. - */ -export function _askRoll({ userId } = {}) { - console.debug(`handleSocketEvent _askRoll from ${userId} !`) - const currentUser = game.user._id - if (userId === currentUser) { - foundry.audio.AudioHelper.play({ src: "/systems/fvtt-cthulhu-eternal/sounds/drums.wav", volume: 0.8, autoplay: true, loop: false }, false) - } -} diff --git a/module/utils.mjs b/module/utils.mjs index 1c8cc1b..3698dff 100644 --- a/module/utils.mjs +++ b/module/utils.mjs @@ -3,9 +3,9 @@ export default class CthulhuEternalUtils { static registerSettings() { game.settings.register("fvtt-cthulhu-eternal", "settings-era", { - name: game.i18n.localize("CHTUHLUETERNAL.Settings.era"), - hint: game.i18n.localize("CHTUHLUETERNAL.Settings.eraHint"), - default: true, + name: game.i18n.localize("CTHULHUETERNAL.Settings.era"), + hint: game.i18n.localize("CTHULHUETERNAL.Settings.eraHint"), + default: "jazz", scope: "world", type: String, choices: SYSTEM.AVAILABLE_SETTINGS, diff --git a/packs-system/skills/000070.log b/packs-system/skills/000070.log deleted file mode 100644 index e69de29..0000000 diff --git a/packs-system/skills/CURRENT b/packs-system/skills/CURRENT index 284d53f..f24fe8e 100644 --- a/packs-system/skills/CURRENT +++ b/packs-system/skills/CURRENT @@ -1 +1 @@ -MANIFEST-000068 +MANIFEST-000076 diff --git a/packs-system/skills/LOG b/packs-system/skills/LOG index bbfae65..375d72c 100644 --- a/packs-system/skills/LOG +++ b/packs-system/skills/LOG @@ -1,8 +1,8 @@ -2025/01/25-18:18:47.579516 7f69797fa6c0 Recovering log #66 -2025/01/25-18:18:47.635623 7f69797fa6c0 Delete type=3 #64 -2025/01/25-18:18:47.635705 7f69797fa6c0 Delete type=0 #66 -2025/01/25-18:23:50.402055 7f6978bff6c0 Level-0 table #71: started -2025/01/25-18:23:50.402099 7f6978bff6c0 Level-0 table #71: 0 bytes OK -2025/01/25-18:23:50.411525 7f6978bff6c0 Delete type=0 #69 -2025/01/25-18:23:50.411705 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) -2025/01/25-18:23:50.411749 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/25-20:17:02.992814 7f697a7fc6c0 Recovering log #74 +2025/01/25-20:17:03.002900 7f697a7fc6c0 Delete type=3 #72 +2025/01/25-20:17:03.002968 7f697a7fc6c0 Delete type=0 #74 +2025/01/25-20:19:31.386247 7f6978bff6c0 Level-0 table #79: started +2025/01/25-20:19:31.386288 7f6978bff6c0 Level-0 table #79: 0 bytes OK +2025/01/25-20:19:31.417028 7f6978bff6c0 Delete type=0 #77 +2025/01/25-20:19:31.593890 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/25-20:19:31.593942 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) diff --git a/packs-system/skills/LOG.old b/packs-system/skills/LOG.old index 6de0933..12a7984 100644 --- a/packs-system/skills/LOG.old +++ b/packs-system/skills/LOG.old @@ -1,8 +1,8 @@ -2025/01/25-17:02:58.822790 7f6979ffb6c0 Recovering log #62 -2025/01/25-17:02:58.899589 7f6979ffb6c0 Delete type=3 #60 -2025/01/25-17:02:58.899681 7f6979ffb6c0 Delete type=0 #62 -2025/01/25-18:12:05.328260 7f6978bff6c0 Level-0 table #67: started -2025/01/25-18:12:05.328291 7f6978bff6c0 Level-0 table #67: 0 bytes OK -2025/01/25-18:12:05.334284 7f6978bff6c0 Delete type=0 #65 -2025/01/25-18:12:05.334447 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) -2025/01/25-18:12:05.362492 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/25-20:09:49.585129 7f697a7fc6c0 Recovering log #70 +2025/01/25-20:09:49.662901 7f697a7fc6c0 Delete type=3 #68 +2025/01/25-20:09:49.662960 7f697a7fc6c0 Delete type=0 #70 +2025/01/25-20:11:19.050068 7f6978bff6c0 Level-0 table #75: started +2025/01/25-20:11:19.050103 7f6978bff6c0 Level-0 table #75: 0 bytes OK +2025/01/25-20:11:19.078755 7f6978bff6c0 Delete type=0 #73 +2025/01/25-20:11:19.078917 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) +2025/01/25-20:11:19.078946 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) diff --git a/packs-system/skills/MANIFEST-000068 b/packs-system/skills/MANIFEST-000068 deleted file mode 100644 index 7b8cea0ecbf2559d2cd16427c835cae8d29a5bf2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmdmC8h9Xufss)vC$%g!CnZVGsj?)sJhM2}IX|}`u_&=5zlfcQ_1HlkMa8uIoRrj} zVnr7h3u9wLkCa4{qKq=vG)u;A1~8CU%q&UGEmo{5$f*i(H#P{2@CXemEiPj0g2*dY eymjVeU}SRTWMFn?*`<10QmsdNhaw4 diff --git a/system.json b/system.json index 729a019..c1de2a2 100644 --- a/system.json +++ b/system.json @@ -1,7 +1,7 @@ { "id": "fvtt-cthulhu-eternal", "title": "Cthulhu Eternal RPG", - "description": "", + "description": "The OGL Cthulhu Eternal RPG system for Foundry VTT", "manifest": "https://www.uberwald.me/gitea/public/fvtt-cthulhu-eternal/raw/branch/main/system.json", "download": "#{DOWNLOAD}#", "url": "https://www.uberwald.me/gitea/public/fvtt-cthulhu-eternal", @@ -66,5 +66,5 @@ }, "primaryTokenAttribute": "hp", "socket": true, - "background": "systems/fvtt-cthulhu-eternal/assets/background.webp" + "background": "systems/fvtt-cthulhu-eternal/assets/ui/background_01.webp" }