Sync bol for module releas
This commit is contained in:
parent
f882a04c0b
commit
fe4ab720ce
@ -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, {})
|
||||
}
|
||||
}
|
||||
|
@ -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": {
|
||||
|
@ -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 = `
|
||||
<i class="fas fa-dice-d20"></i> ${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
|
||||
}
|
@ -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<void>} 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)
|
||||
}
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -1 +1 @@
|
||||
MANIFEST-000068
|
||||
MANIFEST-000076
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Binary file not shown.
@ -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"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user