Initial import with skill sheet worning

This commit is contained in:
2024-11-30 08:38:13 +01:00
parent 2e96b256fb
commit df8995f8b7
52 changed files with 6986 additions and 2189 deletions

View File

@ -12,11 +12,12 @@ import * as documents from "./module/documents/_module.mjs"
import * as applications from "./module/applications/_module.mjs"
import { handleSocketEvent } from "./module/socket.mjs"
import { configureDiceSoNice } from "./module/dice.mjs"
import { Macros } from "./module/macros.mjs"
import { initControlButtons } from "./module/control-buttons.mjs"
import { setupTextEnrichers } from "./module/enrichers.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)}}}
Hooks.once("init", function () {
console.info("Lethal Fantasy RPG | Initializing System")
console.info(SYSTEM.ASCII)
@ -39,12 +40,13 @@ Hooks.once("init", function () {
CONFIG.Item.documentClass = documents.LethalFantasyItem
CONFIG.Item.dataModels = {
path: models.LethalFantasyPath,
talent: models.LethalFantasyTalent,
skill: models.LethalFantasySkill,
gift: models.LethalFantasyGift,
weapon: models.LethalFantasyWeapon,
armor: models.LethalFantasyArmor,
spell: models.LethalFantasySpell,
attack: models.LethalFantasyAttack,
save: models.LethalFantasySave,
vulnerability: models.LethalFantasyVulnerability
}
// Register sheet application classes
@ -53,12 +55,13 @@ Hooks.once("init", function () {
Actors.registerSheet("lethalFantasy", applications.LethalFantasyOpponentSheet, { types: ["opponent"], makeDefault: true })
Items.unregisterSheet("core", ItemSheet)
Items.registerSheet("lethalFantasy", applications.LethalFantasyTalentSheet, { types: ["talent"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyPathSheet, { types: ["path"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasySkillSheet, { types: ["skill"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyGiftSheet, { types: ["gift"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyVulnerabilitySheet, { types: ["vulnerability"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasySaveSheet, { types: ["save"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyWeaponSheet, { types: ["weapon"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasySpellSheet, { types: ["spell"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyArmorSheet, { types: ["armor"], makeDefault: true })
Items.registerSheet("lethalFantasy", applications.LethalFantasyAttackSheet, { types: ["attack"], makeDefault: true })
// Other Document Configuration
CONFIG.ChatMessage.documentClass = documents.LethalFantasyChatMessage
@ -140,9 +143,7 @@ function preLocalizeConfig() {
}
Hooks.once("ready", function () {
console.info("CTHULHU TENEBRIS | Ready")
game.system.applicationFortune = new applications.LethalFantasyFortune()
game.system.applicationFortune.render(true)
console.info("LETHAL FANTASY | Ready")
game.system.applicationManager = new applications.LethalFantasyManager()
if (game.user.isGM) {
game.system.applicationManager.render(true)
@ -159,65 +160,14 @@ Hooks.once("ready", function () {
async function _showUserGuide() {
if (game.user.isGM) {
const newVer = game.system.version
const userGuideJournalName = "Guide du système"
const userGuideCompendiumLabel = "userguide"
let currentVer = "0"
let oldUserGuide = game.journal.getName(userGuideJournalName)
if (oldUserGuide !== undefined && oldUserGuide !== null && oldUserGuide.getFlag("lethalFantasy", "UserGuideVersion") !== undefined) {
currentVer = oldUserGuide.getFlag("lethalFantasy", "UserGuideVersion")
}
if (newVer === currentVer) {
// Up to date
return
}
let newReleasePack = game.packs.find((p) => p.metadata.name === userGuideCompendiumLabel)
if (newReleasePack === null || newReleasePack === undefined) {
console.info("CTHULHU TENEBRIS | No compendium found for the system guide")
return
}
await newReleasePack.getIndex()
let newUserGuide = newReleasePack.index.find((j) => j.name === userGuideJournalName)
if (newUserGuide === undefined || newUserGuide === null) {
console.info("CTHULHU TENEBRIS | No system guide found in the compendium")
return
}
// Don't delete until we have new release Pack
if (oldUserGuide !== null && oldUserGuide !== undefined) {
await oldUserGuide.delete()
}
await game.journal.importFromCompendium(newReleasePack, newUserGuide._id)
let newReleaseJournal = game.journal.getName(newUserGuide.name)
await newReleaseJournal.setFlag("lethalFantasy", "UserGuideVersion", newVer)
// Show journal
await newReleaseJournal.sheet.render(true, { sheetMode: "text" })
}
}
})
Hooks.on("renderChatMessage", (message, html, data) => {
const typeMessage = data.message.flags.lethalFantasy?.typeMessage
// Message de fortune
if (typeMessage === "fortune") {
if (game.user.isGM && !data.message.flags.lethalFantasy?.accepted) {
html.find(".button").click((event) => applications.LethalFantasyFortune.acceptRequest(event, html, data))
} else {
html.find(".button").each((i, btn) => {
btn.style.display = "none"
})
if (game.user.isGM) {
html.find(".fortune-accepted").each((i, btn) => (btn.style.display = "flex"))
}
}
}
// Message de demande de jet de dés
else if (typeMessage === "askRoll") {
if (typeMessage === "askRoll") {
// Affichage des boutons de jet de dés uniquement pour les joueurs
if (game.user.isGM) {
html.find(".ask-roll-dice").each((i, btn) => {
@ -238,9 +188,6 @@ Hooks.on("renderChatMessage", (message, html, data) => {
})
Hooks.on("updateSetting", async (setting, update, options, id) => {
if (setting.key === "lethalFantasy.fortune") {
game.system.applicationFortune.render(true)
}
})
// Dice-so-nice Ready
@ -256,7 +203,7 @@ Hooks.once("diceSoNiceReady", (dice3d) => {
*/
Hooks.on("hotbarDrop", (bar, data, slot) => {
if (["Actor", "Item", "JournalEntry", "roll", "rollDamage", "rollAttack"].includes(data.type)) {
Macros.createLethalFantasyMacro(data, slot)
Macros.createLethalFantasyMacro(data, slot);
return false
}
})
@ -267,29 +214,6 @@ Hooks.on("hotbarDrop", (bar, data, slot) => {
*/
function registerWorldCount(registerKey) {
if (game.user.isGM) {
let worldKey = game.settings.get(registerKey, "worldKey")
if (worldKey === undefined || worldKey === "") {
worldKey = foundry.utils.randomID(32)
game.settings.set(registerKey, "worldKey", worldKey)
}
// Simple API counter
const worldData = {
register_key: registerKey,
world_key: worldKey,
foundry_version: `${game.release.generation}.${game.release.build}`,
system_name: game.system.id,
system_version: game.system.version,
}
let apiURL = "https://worlds.qawstats.info/worlds-counter"
$.ajax({
url: apiURL,
type: "POST",
data: JSON.stringify(worldData),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
})
ClassCounter.registerUsageCount(game.system.id, {})
}
}