Portraits et corrections sur valeurs des PNJ
Some checks failed
Release Creation / build (release) Failing after 1m24s
Some checks failed
Release Creation / build (release) Failing after 1m24s
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
|
||||
const DAMAGE_APPLICATION_FLAG = "damageApplication"
|
||||
const FACTION_ASPECT_STATE_SETTING = "factionAspectState"
|
||||
const PREGENS_IMPORTED_SETTING = "pregensImported"
|
||||
const WELCOME_SCENE_IMPORTED_SETTING = "welcomeSceneImported"
|
||||
|
||||
/* ─── Init hook ──────────────────────────────────────────────────────────── */
|
||||
@@ -179,7 +180,9 @@ Hooks.once("ready", async () => {
|
||||
if (game.user.isGM) {
|
||||
_migrateObsoleteItems()
|
||||
_migrateIntegerTracks()
|
||||
_setupAnomaliesFolder()
|
||||
_migrateBiographyFields()
|
||||
await _setupAnomaliesFolder()
|
||||
await _setupPregensFolder()
|
||||
await _setupWelcomeScene()
|
||||
}
|
||||
|
||||
@@ -271,6 +274,31 @@ async function _migrateIntegerTracks() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Migration : ajoute les champs de biographie manquants sur les fiches existantes. */
|
||||
async function _migrateBiographyFields() {
|
||||
const actors = game.actors.contents.filter(actor => ["character", "npc"].includes(actor.type))
|
||||
|
||||
for (const actor of actors) {
|
||||
const src = actor._source?.system
|
||||
if (!src) continue
|
||||
|
||||
const updateData = {}
|
||||
|
||||
if (actor.type === "character" && !("historique" in src)) {
|
||||
updateData["system.historique"] = ""
|
||||
}
|
||||
|
||||
if (!("portraitImage" in src)) {
|
||||
updateData["system.portraitImage"] = ""
|
||||
}
|
||||
|
||||
if (Object.keys(updateData).length > 0) {
|
||||
console.log(`${SYSTEM_ID} | Migration biographie : ${actor.name}`, updateData)
|
||||
await actor.update(updateData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ─── Handlebars helpers ─────────────────────────────────────────────────── */
|
||||
|
||||
function _registerHandlebarsHelpers() {
|
||||
@@ -347,6 +375,12 @@ function _registerSettings() {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
})
|
||||
game.settings.register(SYSTEM_ID, PREGENS_IMPORTED_SETTING, {
|
||||
scope: "world",
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: false,
|
||||
})
|
||||
game.settings.register(SYSTEM_ID, FACTION_ASPECT_STATE_SETTING, {
|
||||
scope: "world",
|
||||
config: false,
|
||||
@@ -428,6 +462,34 @@ async function _setupWelcomeScene() {
|
||||
await game.settings.set(SYSTEM_ID, WELCOME_SCENE_IMPORTED_SETTING, true)
|
||||
}
|
||||
|
||||
async function _setupPregensFolder() {
|
||||
const activeGM = game.users.activeGM
|
||||
if (!game.user.isGM || (activeGM && activeGM.id !== game.user.id)) return
|
||||
if (game.settings.get(SYSTEM_ID, PREGENS_IMPORTED_SETTING)) return
|
||||
|
||||
const pack = game.packs.get(`${SYSTEM_ID}.pretires`)
|
||||
if (!pack) {
|
||||
console.warn(`${SYSTEM_ID} | Compendium de prétirés introuvable`)
|
||||
return
|
||||
}
|
||||
|
||||
const folderName = game.i18n.localize("CELESTOPOL.Pregens.folderName")
|
||||
let folder = game.folders.contents.find(f => f.type === "Actor" && f.name === folderName)
|
||||
if (!folder) {
|
||||
folder = await Folder.create({
|
||||
name: folderName,
|
||||
type: "Actor",
|
||||
color: "#1b3828",
|
||||
})
|
||||
}
|
||||
|
||||
console.log(`${SYSTEM_ID} | Premier lancement : import des prétirés dans le monde`)
|
||||
await pack.importAll({ folderId: folder.id, keepId: true })
|
||||
await game.settings.set(SYSTEM_ID, PREGENS_IMPORTED_SETTING, true)
|
||||
console.log(`${SYSTEM_ID} | Prétirés importés avec succès dans le dossier "${folder.name}"`)
|
||||
ui.notifications.info(game.i18n.localize("CELESTOPOL.Pregens.imported"))
|
||||
}
|
||||
|
||||
/* ─── Template preload ───────────────────────────────────────────────────── */
|
||||
|
||||
function _preloadTemplates() {
|
||||
|
||||
Reference in New Issue
Block a user