This commit is contained in:
+25
-43
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
import { SYSTEM } from "./module/config/system.mjs"
|
||||
globalThis.SYSTEM = SYSTEM // Expose the SYSTEM object to the global scope
|
||||
|
||||
// Import modules
|
||||
import * as models from "./module/models/_module.mjs"
|
||||
@@ -14,15 +13,24 @@ import * as applications from "./module/applications/_module.mjs"
|
||||
import { LethalFantasyCombatTracker, LethalFantasyCombat } from "./module/applications/combat.mjs"
|
||||
import { Macros } from "./module/macros.mjs"
|
||||
import { setupTextEnrichers } from "./module/enrichers.mjs"
|
||||
import { default as LethalFantasyUtils } 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) } } }
|
||||
import LethalFantasyUtils, { log } from "./module/utils.mjs"
|
||||
|
||||
Hooks.once("init", function () {
|
||||
globalThis.SYSTEM = SYSTEM
|
||||
globalThis.pendingDefenses = new Map()
|
||||
console.info("Lethal Fantasy RPG | Initializing System")
|
||||
console.info(SYSTEM.ASCII)
|
||||
|
||||
game.settings.register(game.system.id, "debug", {
|
||||
name: "Debug logging",
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: false,
|
||||
type: Boolean,
|
||||
})
|
||||
|
||||
globalThis.lethalFantasy = game.system
|
||||
globalThis.log = log
|
||||
game.system.CONST = SYSTEM
|
||||
|
||||
// Expose the system API
|
||||
@@ -54,12 +62,10 @@ Hooks.once("init", function () {
|
||||
miracle: models.LethalFantasyMiracle
|
||||
}
|
||||
|
||||
// Register sheet application classes
|
||||
foundry.documents.collections.Actors.unregisterSheet("core", foundry.appv1.sheets.ActorSheet)
|
||||
// Register sheet application classes (V2)
|
||||
foundry.documents.collections.Actors.registerSheet("lethalFantasy", applications.LethalFantasyCharacterSheet, { types: ["character"], makeDefault: true })
|
||||
foundry.documents.collections.Actors.registerSheet("lethalFantasy", applications.LethalFantasyMonsterSheet, { types: ["monster"], makeDefault: true })
|
||||
|
||||
foundry.documents.collections.Items.unregisterSheet("core", foundry.appv1.sheets.ActorSheet)
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasySkillSheet, { types: ["skill"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyGiftSheet, { types: ["gift"], makeDefault: true })
|
||||
foundry.documents.collections.Items.registerSheet("lethalFantasy", applications.LethalFantasyVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true })
|
||||
@@ -76,14 +82,6 @@ Hooks.once("init", function () {
|
||||
// Dice system configuration
|
||||
CONFIG.Dice.rolls.push(documents.LethalFantasyRoll)
|
||||
|
||||
game.settings.register("lethalFantasy", "worldKey", {
|
||||
name: "Unique world key",
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: String,
|
||||
default: "",
|
||||
})
|
||||
|
||||
// Activate socket handler
|
||||
game.socket.on(`system.${SYSTEM.id}`, LethalFantasyUtils.handleSocketEvent)
|
||||
|
||||
@@ -113,10 +111,6 @@ Hooks.once("ready", function () {
|
||||
// Initialiser la table des résultats D30
|
||||
documents.D30Roll.initialize()
|
||||
|
||||
if (!SYSTEM.DEV_MODE) {
|
||||
registerWorldCount("lethalFantasy")
|
||||
}
|
||||
|
||||
// Saignement piloté par le combat tracker
|
||||
_registerBleedingHooks()
|
||||
|
||||
@@ -333,7 +327,7 @@ Hooks.on("renderChatMessageHTML", (message, html, data) => {
|
||||
? (rollTargetData?._id || rollTargetData?.id)
|
||||
: (rollTargetData?.weapon?.id || rollTargetData?.weapon?._id)
|
||||
const attackRollKey = rollTargetData?.rollKey
|
||||
console.log(`[LF] request-defense-btn | attackRollType=${attackRollType} defender=${defenderName} defenderType=${combatant.actor?.type}`)
|
||||
log(`[LF] request-defense-btn | attackRollType=${attackRollType} defender=${defenderName} defenderType=${combatant.actor?.type}`)
|
||||
const attackD30result = message.rolls[0]?.options?.D30result || null
|
||||
const attackD30message = message.rolls[0]?.options?.D30message || null
|
||||
const attackDiceResults = message.rolls[0]?.options?.diceResults || null
|
||||
@@ -552,7 +546,7 @@ Hooks.on("preCreateChatMessage", (message) => {
|
||||
[`flags.${SYSTEM.id}.attackData`]: game.lethalFantasy.nextDefenseData
|
||||
})
|
||||
|
||||
console.log("Added attack data to defense message:", game.lethalFantasy.nextDefenseData)
|
||||
log("Added attack data to defense message:", game.lethalFantasy.nextDefenseData)
|
||||
|
||||
// Nettoyer
|
||||
delete game.lethalFantasy.nextDefenseData
|
||||
@@ -563,7 +557,7 @@ Hooks.on("preCreateChatMessage", (message) => {
|
||||
Hooks.on("createChatMessage", async (message) => {
|
||||
const rollType = message.rolls[0]?.options?.rollType
|
||||
|
||||
console.log("Defense hook checking message, rollType:", rollType)
|
||||
log("Defense hook checking message, rollType:", rollType)
|
||||
|
||||
// Vérifier si c'est un message de défense
|
||||
if (rollType !== "weapon-defense" && rollType !== "monster-defense" && rollType !== "save") return
|
||||
@@ -571,10 +565,10 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
// Récupérer les données d'attaque depuis les flags
|
||||
const attackData = message.flags?.[SYSTEM.id]?.attackData
|
||||
|
||||
console.log("Defense message confirmed, attackData:", attackData)
|
||||
log("Defense message confirmed, attackData:", attackData)
|
||||
|
||||
if (!attackData) {
|
||||
console.log("No attack data found in message flags")
|
||||
log("No attack data found in message flags")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -596,7 +590,7 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
let defenseRoll = message.rolls[0]?.options?.rollTotal || message.rolls[0]?.total || 0
|
||||
const defenseD30message = message.rolls[0]?.options?.D30message || null
|
||||
|
||||
console.log("Processing defense:", { attackRoll, defenseRoll, attackerId, defenderId })
|
||||
log("Processing defense:", { attackRoll, defenseRoll, attackerId, defenderId })
|
||||
|
||||
// Attendre l'animation 3D
|
||||
if (game?.dice3d) {
|
||||
@@ -1058,7 +1052,7 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
))
|
||||
|
||||
if (shouldCreateMessage) {
|
||||
console.log("Creating comparison message", { attackerHandledBonus, defenderHandledBonus, isDefenderOwner: defender.isOwner })
|
||||
log("Creating comparison message", { attackerHandledBonus, defenderHandledBonus, isDefenderOwner: defender.isOwner })
|
||||
|
||||
await LethalFantasyUtils.compareAttackDefense({
|
||||
attackerName,
|
||||
@@ -1080,7 +1074,7 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
attackD30message
|
||||
})
|
||||
} else {
|
||||
console.log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus })
|
||||
log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus })
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1161,7 +1155,7 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
const defenderId = message.rolls[0]?.options?.defenderId
|
||||
const isDamage = message.rolls[0]?.options?.rollData?.isDamage
|
||||
|
||||
console.log("Auto-damage hook:", { defenderId, isDamage, rollType: message.rolls[0]?.options?.rollType })
|
||||
log("Auto-damage hook:", { defenderId, isDamage, rollType: message.rolls[0]?.options?.rollType })
|
||||
|
||||
if (!defenderId || !isDamage) return
|
||||
|
||||
@@ -1186,11 +1180,11 @@ Hooks.on("createChatMessage", async (message) => {
|
||||
}
|
||||
|
||||
if (!shouldApplyDamage) {
|
||||
console.log("Auto-damage hook: Not responsible for applying damage, skipping")
|
||||
log("Auto-damage hook: Not responsible for applying damage, skipping")
|
||||
return
|
||||
}
|
||||
|
||||
console.log("Auto-damage hook: Applying damage as responsible user")
|
||||
log("Auto-damage hook: Applying damage as responsible user")
|
||||
|
||||
// Attendre l'animation 3D avant d'appliquer les dégâts
|
||||
if (game?.dice3d) {
|
||||
@@ -1401,16 +1395,4 @@ Hooks.on("hotbarDrop", (bar, data, slot) => {
|
||||
*/
|
||||
Hooks.on("renderChatLog", (_chatLog, html) => applications.injectDiceTray(_chatLog, html))
|
||||
|
||||
/**
|
||||
* Register world usage statistics
|
||||
* @param {string} registerKey
|
||||
*/
|
||||
async function registerWorldCount(registerKey) {
|
||||
if (game.user.isGM) {
|
||||
try {
|
||||
ClassCounter.registerUsageCount(game.system.id, {})
|
||||
} catch {
|
||||
console.log("No usage log ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user