Cleanup init & start
- classe SystemReveDeDragon pour l'init/start - déplacement de la migration 1.5.34 dans les migrations
This commit is contained in:
parent
70b30b545b
commit
7bec249e8d
@ -29,6 +29,39 @@ class Migration {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _1_5_34_migrationPngWebp {
|
||||||
|
get code() { return "migrationPngWebp"; }
|
||||||
|
get version() { return "1.5.34"; }
|
||||||
|
async migrate() {
|
||||||
|
|
||||||
|
const regexOldPngJpg = /(systems\/foundryvtt-reve-de-dragon\/icons\/.*)\.(png|jpg)/;
|
||||||
|
const replaceWithWebp = '$1.webp';
|
||||||
|
function convertImgToWebp(img) {
|
||||||
|
return img.replace(regexOldPngJpg, replaceWithWebp);
|
||||||
|
}
|
||||||
|
function prepareDocumentsImgUpdate(documents) {
|
||||||
|
return documents.filter(it => it.img && it.img.match(regexOldPngJpg))
|
||||||
|
.map(it => {
|
||||||
|
return { _id: it.id, img: convertImgToWebp(it.img) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemsUpdates = prepareDocumentsImgUpdate(game.items);
|
||||||
|
const actorsUpdates = prepareDocumentsImgUpdate(game.actors);
|
||||||
|
//Migrate system png to webp
|
||||||
|
await Item.updateDocuments(itemsUpdates);
|
||||||
|
await Actor.updateDocuments(actorsUpdates);
|
||||||
|
game.actors.forEach(actor => {
|
||||||
|
if (actor.token?.img && actor.token.img.match(regexOldPngJpg)) {
|
||||||
|
actor.update({ "token.img": convertImgToWebp(actor.token.img) });
|
||||||
|
}
|
||||||
|
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
||||||
|
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class _10_0_16_MigrationSortsReserve extends Migration {
|
class _10_0_16_MigrationSortsReserve extends Migration {
|
||||||
get code() { return "creation-item-sort-reserve"; }
|
get code() { return "creation-item-sort-reserve"; }
|
||||||
get version() { return "10.0.16"; }
|
get version() { return "10.0.16"; }
|
||||||
@ -296,6 +329,7 @@ class _10_3_17_Monnaies extends Migration {
|
|||||||
export class Migrations {
|
export class Migrations {
|
||||||
static getMigrations() {
|
static getMigrations() {
|
||||||
return [
|
return [
|
||||||
|
new _1_5_34_migrationPngWebp(),
|
||||||
new _10_0_16_MigrationSortsReserve(),
|
new _10_0_16_MigrationSortsReserve(),
|
||||||
new _10_0_17_MigrationCompetenceCreature(),
|
new _10_0_17_MigrationCompetenceCreature(),
|
||||||
new _10_0_21_VehiculeStructureResistanceMax(),
|
new _10_0_21_VehiculeStructureResistanceMax(),
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { Misc } from "./misc.js";
|
|
||||||
|
|
||||||
export class RdDHotbar {
|
export class RdDHotbar {
|
||||||
|
|
||||||
|
@ -1,13 +1,3 @@
|
|||||||
/**
|
|
||||||
* RdD system
|
|
||||||
* Author: LeRatierBretonnien
|
|
||||||
* Software License: GNU GPLv3
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
// Import Modules
|
|
||||||
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
||||||
import { RdDActor } from "./actor.js";
|
import { RdDActor } from "./actor.js";
|
||||||
import { RdDItemSheet } from "./item-sheet.js";
|
import { RdDItemSheet } from "./item-sheet.js";
|
||||||
@ -45,301 +35,272 @@ import { RdDIngredientItemSheet } from "./item-ingredient-sheet.js";
|
|||||||
import { RdDFauneItemSheet } from "./item-faune-sheet.js";
|
import { RdDFauneItemSheet } from "./item-faune-sheet.js";
|
||||||
import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js";
|
import { RdDConteneurItemSheet } from "./item-conteneur-sheet.js";
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/**
|
||||||
/* Foundry VTT Initialization */
|
* RdD system
|
||||||
/* -------------------------------------------- */
|
* Author: LeRatierBretonnien
|
||||||
|
* Software License: GNU GPLv3
|
||||||
|
*/
|
||||||
|
export class SystemReveDeDragon {
|
||||||
|
|
||||||
|
static start() {
|
||||||
|
const system = new SystemReveDeDragon();
|
||||||
|
Hooks.once('init', async () => await system.onInit());
|
||||||
|
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor() {
|
||||||
/************************************************************************************/
|
this.RdDUtility = RdDUtility;
|
||||||
Hooks.once("init", async function () {
|
this.RdDHotbar = RdDHotbar;
|
||||||
console.log(`Initializing Reve de Dragon System`);
|
|
||||||
|
|
||||||
// preload handlebars templates
|
|
||||||
RdDUtility.preloadHandlebarsTemplates();
|
|
||||||
// Create useful storage space
|
|
||||||
game.system.rdd = {
|
|
||||||
TMRUtility,
|
|
||||||
RdDUtility,
|
|
||||||
RdDHotbar,
|
|
||||||
RdDPossession,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
/* Foundry VTT Initialization */
|
||||||
name: "Accorder le rêve aux entités",
|
|
||||||
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar",
|
|
||||||
scope: "world",
|
|
||||||
config: true,
|
|
||||||
type: String,
|
|
||||||
choices: { // If choices are defined, the resulting setting will be a select menu
|
|
||||||
"avant-attaque": "Avant l'attaque",
|
|
||||||
"avant-defense": "Avant la défense",
|
|
||||||
"avant-encaissement": "Avant l'encaissement",
|
|
||||||
},
|
|
||||||
default: "avant-encaissement"
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "calendrier", {
|
async onInit() {
|
||||||
name: "calendrier",
|
game.system.rdd = this;
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: RdDCalendrier.createCalendrierInitial(),
|
|
||||||
type: Object
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
console.log(`Initializing Reve de Dragon System`);
|
||||||
game.settings.register(SYSTEM_RDD, "migration-png-webp-1.5.34", {
|
|
||||||
name: "calendrier",
|
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: false,
|
|
||||||
type: Boolean
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
// preload handlebars templates
|
||||||
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
RdDUtility.preloadHandlebarsTemplates();
|
||||||
name: "liste-nombre-astral",
|
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: [],
|
|
||||||
type: Object
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "calendrier-pos", {
|
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
||||||
name: "calendrierPos",
|
name: "Accorder le rêve aux entités",
|
||||||
scope: "client",
|
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar",
|
||||||
config: false,
|
scope: "world",
|
||||||
default: RdDCalendrier.createCalendrierPos(),
|
config: true,
|
||||||
type: Object
|
type: String,
|
||||||
});
|
choices: { // If choices are defined, the resulting setting will be a select menu
|
||||||
|
"avant-attaque": "Avant l'attaque",
|
||||||
|
"avant-defense": "Avant la défense",
|
||||||
|
"avant-encaissement": "Avant l'encaissement",
|
||||||
|
},
|
||||||
|
default: "avant-encaissement"
|
||||||
|
});
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
game.settings.register(SYSTEM_RDD, "calendrier", {
|
||||||
|
name: "calendrier",
|
||||||
|
scope: "world",
|
||||||
|
config: false,
|
||||||
|
default: RdDCalendrier.createCalendrierInitial(),
|
||||||
|
type: Object
|
||||||
|
});
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
||||||
|
name: "liste-nombre-astral",
|
||||||
|
scope: "world",
|
||||||
|
config: false,
|
||||||
|
default: [],
|
||||||
|
type: Object
|
||||||
|
});
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
game.settings.register(SYSTEM_RDD, "calendrier-pos", {
|
||||||
|
name: "calendrierPos",
|
||||||
|
scope: "client",
|
||||||
|
config: false,
|
||||||
|
default: RdDCalendrier.createCalendrierPos(),
|
||||||
|
type: Object
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", {
|
game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", {
|
||||||
name: "Supprimer les dialogues de combat",
|
name: "Supprimer les dialogues de combat",
|
||||||
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
|
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
|
||||||
scope: "world",
|
scope: "world",
|
||||||
config: true,
|
config: true,
|
||||||
default: true,
|
default: true,
|
||||||
type: Boolean
|
type: Boolean
|
||||||
});
|
});
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "activer-sons-audio", {
|
game.settings.register(SYSTEM_RDD, "activer-sons-audio", {
|
||||||
name: "Activer les bruitages intégrés",
|
name: "Activer les bruitages intégrés",
|
||||||
hint: "Si activé, certaines actions en jeu déclenchent un son d'ambiance",
|
hint: "Si activé, certaines actions en jeu déclenchent un son d'ambiance",
|
||||||
scope: "world",
|
scope: "world",
|
||||||
config: true,
|
config: true,
|
||||||
default: true,
|
default: true,
|
||||||
type: Boolean
|
type: Boolean
|
||||||
});
|
});
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.settings.register(SYSTEM_RDD, "appliquer-famine-soif", {
|
game.settings.register(SYSTEM_RDD, "appliquer-famine-soif", {
|
||||||
name: "Notifier de la famine et la soif pour",
|
name: "Notifier de la famine et la soif pour",
|
||||||
hint: "Indique si les cas de famine et de soif seront indiqués durant Château Dormant",
|
hint: "Indique si les cas de famine et de soif seront indiqués durant Château Dormant",
|
||||||
scope: "world",
|
scope: "world",
|
||||||
config: true,
|
config: true,
|
||||||
type: String,
|
type: String,
|
||||||
choices: {
|
choices: {
|
||||||
"aucun": "ni la famine, ni la soif",
|
"aucun": "ni la famine, ni la soif",
|
||||||
"famine": "seulement la famine",
|
"famine": "seulement la famine",
|
||||||
"famine-soif": "la famine et la soif",
|
"famine-soif": "la famine et la soif",
|
||||||
},
|
},
|
||||||
default: "aucun"
|
default: "aucun"
|
||||||
});
|
});
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Set an initiative formula for the system
|
// Set an initiative formula for the system
|
||||||
CONFIG.Combat.initiative = {
|
CONFIG.Combat.initiative = {
|
||||||
formula: "1+(1d6/10)",
|
formula: "1+(1d6/10)",
|
||||||
decimals: 2
|
decimals: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
|
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
|
||||||
console.log(">>>>> MSG RECV", sockmsg);
|
console.log(">>>>> MSG RECV", sockmsg);
|
||||||
try {
|
try {
|
||||||
RdDUtility.onSocketMessage(sockmsg);
|
RdDUtility.onSocketMessage(sockmsg);
|
||||||
RdDCombat.onSocketMessage(sockmsg);
|
RdDCombat.onSocketMessage(sockmsg);
|
||||||
ChatUtility.onSocketMessage(sockmsg);
|
ChatUtility.onSocketMessage(sockmsg);
|
||||||
RdDActor.onSocketMessage(sockmsg);
|
RdDActor.onSocketMessage(sockmsg);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e)
|
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
// Define custom Entity classes
|
||||||
|
CONFIG.Actor.documentClass = RdDActor;
|
||||||
|
CONFIG.Item.documentClass = RdDItem;
|
||||||
|
CONFIG.RDD = {
|
||||||
|
resolutionTable: RdDResolutionTable.resolutionTable,
|
||||||
|
carac_array: RdDUtility.getCaracArray(),
|
||||||
|
ajustementsConditions: RdDUtility.getAjustementsConditions(),
|
||||||
|
difficultesLibres: RdDUtility.getDifficultesLibres()
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Define custom Entity classes
|
// Register sheet application classes
|
||||||
CONFIG.Actor.documentClass = RdDActor;
|
Actors.unregisterSheet("core", ActorSheet);
|
||||||
CONFIG.Item.documentClass = RdDItem;
|
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true });
|
||||||
CONFIG.RDD = {
|
Actors.registerSheet(SYSTEM_RDD, RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
|
||||||
resolutionTable: RdDResolutionTable.resolutionTable,
|
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
||||||
carac_array: RdDUtility.getCaracArray(),
|
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
||||||
ajustementsConditions: RdDUtility.getAjustementsConditions(),
|
Items.unregisterSheet("core", ItemSheet);
|
||||||
difficultesLibres: RdDUtility.getDifficultesLibres()
|
|
||||||
|
RdDItemSheet.register(RdDSigneDraconiqueItemSheet);
|
||||||
|
RdDItemSheet.register(RdDRencontreItemSheet);
|
||||||
|
RdDItemSheet.register(RdDConteneurItemSheet);
|
||||||
|
RdDItemSheet.register(RdDHerbeItemSheet);
|
||||||
|
RdDItemSheet.register(RdDFauneItemSheet);
|
||||||
|
RdDItemSheet.register(RdDIngredientItemSheet);
|
||||||
|
|
||||||
|
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
|
||||||
|
types: [
|
||||||
|
"competence", "competencecreature",
|
||||||
|
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
||||||
|
"objet", "arme", "armure", "livre", "potion", "munition",
|
||||||
|
"monnaie", "nourritureboisson", "gemme",
|
||||||
|
"meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
||||||
|
"nombreastral", "tache", "maladie", "poison", "possession",
|
||||||
|
"tarot", "extraitpoetique"
|
||||||
|
], makeDefault: true
|
||||||
|
});
|
||||||
|
CONFIG.Combat.documentClass = RdDCombatManager;
|
||||||
|
|
||||||
|
// préparation des différents modules
|
||||||
|
SystemCompendiums.init();
|
||||||
|
DialogChronologie.init();
|
||||||
|
ReglesOptionelles.init();
|
||||||
|
RdDUtility.init();
|
||||||
|
RdDDice.init();
|
||||||
|
RdDCommands.init();
|
||||||
|
RdDCombat.init();
|
||||||
|
RdDCombatManager.init();
|
||||||
|
RdDTokenHud.init();
|
||||||
|
RdDActor.init();
|
||||||
|
RddCompendiumOrganiser.init();
|
||||||
|
EffetsDraconiques.init()
|
||||||
|
TMRUtility.init();
|
||||||
|
RdDHotbar.initDropbar();
|
||||||
|
RdDPossession.init();
|
||||||
|
TMRRencontres.init();
|
||||||
|
Environnement.init();
|
||||||
|
|
||||||
|
Hooks.once('ready', () => this.onReady());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onReady() {
|
||||||
|
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* Foundry VTT Initialization */
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
// CSS patch for v9
|
||||||
|
if (game.version) {
|
||||||
|
let sidebar = document.getElementById("sidebar");
|
||||||
|
sidebar.style.width = "min-content";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Misc.isUniqueConnectedGM()) {
|
||||||
|
new Migrations().migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusEffects.onReady();
|
||||||
|
RdDHerbes.initializeHerbes();
|
||||||
|
RdDDice.onReady();
|
||||||
|
/* -------------------------------------------- */
|
||||||
|
/* Affiche/Init le calendrier */
|
||||||
|
let calendrier = new RdDCalendrier();
|
||||||
|
let templatePath = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
||||||
|
let templateData = {};
|
||||||
|
renderTemplate(templatePath, templateData).then(html => {
|
||||||
|
calendrier.render(true);
|
||||||
|
});
|
||||||
|
game.system.rdd.calendrier = calendrier; // Reference;
|
||||||
|
|
||||||
|
// Avertissement si joueur sans personnage
|
||||||
|
if (!game.user.isGM && game.user.character == undefined) {
|
||||||
|
ui.notifications.info("Attention ! Vous n'êtes connecté à aucun personnage !");
|
||||||
|
ChatMessage.create({
|
||||||
|
content: "<b>ATTENTION</b> Le joueur " + game.user.name + " n'est connecté à aucun personnage !",
|
||||||
|
user: game.user.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (Misc.isUniqueConnectedGM()) {
|
||||||
|
this.messageDeBienvenue();
|
||||||
|
this.registerUsageCount(SYSTEM_RDD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
// Register sheet application classes
|
messageDeBienvenue() {
|
||||||
Actors.unregisterSheet("core", ActorSheet);
|
if (game.user.isGM) {
|
||||||
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true });
|
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
||||||
Actors.registerSheet(SYSTEM_RDD, RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
|
ChatMessage.create({
|
||||||
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
user: game.user.id,
|
||||||
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
||||||
Items.unregisterSheet("core", ItemSheet);
|
|
||||||
|
|
||||||
RdDItemSheet.register(RdDSigneDraconiqueItemSheet);
|
|
||||||
RdDItemSheet.register(RdDRencontreItemSheet);
|
|
||||||
RdDItemSheet.register(RdDConteneurItemSheet);
|
|
||||||
RdDItemSheet.register(RdDHerbeItemSheet);
|
|
||||||
RdDItemSheet.register(RdDFauneItemSheet);
|
|
||||||
RdDItemSheet.register(RdDIngredientItemSheet);
|
|
||||||
|
|
||||||
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
|
|
||||||
types: [
|
|
||||||
"competence", "competencecreature",
|
|
||||||
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
|
||||||
"objet", "arme", "armure", "livre", "potion", "munition",
|
|
||||||
"monnaie", "nourritureboisson", "gemme",
|
|
||||||
"meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
|
||||||
"nombreastral", "tache", "maladie", "poison", "possession",
|
|
||||||
"tarot", "extraitpoetique"
|
|
||||||
], makeDefault: true
|
|
||||||
});
|
|
||||||
CONFIG.Combat.documentClass = RdDCombatManager;
|
|
||||||
|
|
||||||
// préparation des différents modules
|
|
||||||
SystemCompendiums.init();
|
|
||||||
DialogChronologie.init();
|
|
||||||
ReglesOptionelles.init();
|
|
||||||
RdDUtility.init();
|
|
||||||
RdDDice.init();
|
|
||||||
RdDCommands.init();
|
|
||||||
RdDCombat.init();
|
|
||||||
RdDCombatManager.init();
|
|
||||||
RdDTokenHud.init();
|
|
||||||
RdDActor.init();
|
|
||||||
RddCompendiumOrganiser.init();
|
|
||||||
EffetsDraconiques.init()
|
|
||||||
TMRUtility.init();
|
|
||||||
RdDHotbar.initDropbar();
|
|
||||||
RdDPossession.init();
|
|
||||||
TMRRencontres.init();
|
|
||||||
Environnement.init();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
function messageDeBienvenue() {
|
|
||||||
if (game.user.isGM) {
|
|
||||||
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
|
||||||
ChatMessage.create({
|
|
||||||
user: game.user.id,
|
|
||||||
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
|
||||||
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
||||||
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
||||||
` });
|
` });
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
// Register world usage statistics
|
|
||||||
async function registerUsageCount(registerKey) {
|
|
||||||
if (game.user.isGM) {
|
|
||||||
game.settings.register("world", "world-key", {
|
|
||||||
name: "Unique world key",
|
|
||||||
scope: "world",
|
|
||||||
config: false,
|
|
||||||
default: "NONE",
|
|
||||||
type: String
|
|
||||||
});
|
|
||||||
|
|
||||||
let worldKey = game.settings.get("world", "world-key")
|
|
||||||
if (worldKey == undefined || worldKey == "") {
|
|
||||||
worldKey = randomID(32)
|
|
||||||
game.settings.set("world", "world-key", worldKey)
|
|
||||||
}
|
}
|
||||||
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
|
||||||
$.ajax(regURL)
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
/* Foundry VTT Initialization */
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
Hooks.once("ready", async function () {
|
|
||||||
await migrationPngWebp_1_5_34()
|
|
||||||
if (Misc.isUniqueConnectedGM()) {
|
|
||||||
new Migrations().migrate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusEffects.onReady();
|
|
||||||
RdDHerbes.initializeHerbes();
|
|
||||||
RdDDice.onReady();
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
/* Affiche/Init le calendrier */
|
// Register world usage statistics
|
||||||
let calendrier = new RdDCalendrier();
|
async registerUsageCount(registerKey) {
|
||||||
let templatePath = "systems/foundryvtt-reve-de-dragon/templates/calendar-template.html";
|
if (game.user.isGM) {
|
||||||
let templateData = {};
|
game.settings.register("world", "world-key", {
|
||||||
renderTemplate(templatePath, templateData).then(html => {
|
name: "Unique world key",
|
||||||
calendrier.render(true);
|
scope: "world",
|
||||||
});
|
config: false,
|
||||||
game.system.rdd.calendrier = calendrier; // Reference;
|
default: "NONE",
|
||||||
|
type: String
|
||||||
|
});
|
||||||
|
|
||||||
// Avertissement si joueur sans personnage
|
let worldKey = game.settings.get("world", "world-key")
|
||||||
if (!game.user.isGM && game.user.character == undefined) {
|
if (worldKey == undefined || worldKey == "") {
|
||||||
ui.notifications.info("Attention ! Vous n'êtes connecté à aucun personnage !");
|
worldKey = randomID(32)
|
||||||
ChatMessage.create({
|
game.settings.set("world", "world-key", worldKey)
|
||||||
content: "<b>ATTENTION</b> Le joueur " + game.user.name + " n'est connecté à aucun personnage !",
|
|
||||||
user: game.user.id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (Misc.isUniqueConnectedGM()) {
|
|
||||||
messageDeBienvenue();
|
|
||||||
registerUsageCount(SYSTEM_RDD);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function migrationPngWebp_1_5_34() {
|
|
||||||
if (!game.settings.get(SYSTEM_RDD, "migration-png-webp-1.5.34")) {
|
|
||||||
const regexOldPngJpg = /(systems\/foundryvtt-reve-de-dragon\/icons\/.*)\.(png|jpg)/;
|
|
||||||
const replaceWithWebp = '$1.webp';
|
|
||||||
function convertImgToWebp(img) {
|
|
||||||
return img.replace(regexOldPngJpg, replaceWithWebp);
|
|
||||||
}
|
|
||||||
function prepareDocumentsImgUpdate(documents) {
|
|
||||||
return documents.filter(it => it.img && it.img.match(regexOldPngJpg))
|
|
||||||
.map(it => {
|
|
||||||
return { _id: it.id, img: convertImgToWebp(it.img) }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const itemsUpdates = prepareDocumentsImgUpdate(game.items);
|
|
||||||
const actorsUpdates = prepareDocumentsImgUpdate(game.actors);
|
|
||||||
//Migrate system png to webp
|
|
||||||
await Item.updateDocuments(itemsUpdates);
|
|
||||||
await Actor.updateDocuments(actorsUpdates);
|
|
||||||
game.actors.forEach(actor => {
|
|
||||||
if (actor.token?.img && actor.token.img.match(regexOldPngJpg)) {
|
|
||||||
actor.update({ "token.img": convertImgToWebp(actor.token.img) });
|
|
||||||
}
|
}
|
||||||
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
||||||
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
$.ajax(regURL)
|
||||||
});
|
/* -------------------------------------------- */
|
||||||
game.settings.set(SYSTEM_RDD, "migration-png-webp-1.5.34", true)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// CSS patch for v9
|
|
||||||
if (game.version) {
|
|
||||||
let sidebar = document.getElementById("sidebar");
|
|
||||||
sidebar.style.width = "min-content";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
SystemReveDeDragon.start();
|
||||||
/* Dice-so-nice ready */
|
|
||||||
/* -------------------------------------------- */
|
|
||||||
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user