2020-06-07 23:16:50 +02:00
|
|
|
/**
|
|
|
|
* RdD system
|
|
|
|
* Author: LeRatierBretonnien
|
|
|
|
* Software License: GNU GPLv3
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Import Modules
|
2022-01-29 22:49:34 +01:00
|
|
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js";
|
2020-06-07 23:16:50 +02:00
|
|
|
import { RdDActor } from "./actor.js";
|
|
|
|
import { RdDItemSheet } from "./item-sheet.js";
|
|
|
|
import { RdDActorSheet } from "./actor-sheet.js";
|
2020-09-20 17:38:21 +02:00
|
|
|
import { RdDActorCreatureSheet } from "./actor-creature-sheet.js";
|
2021-01-10 22:12:07 +01:00
|
|
|
import { RdDActorVehiculeSheet } from "./actor-vehicule-sheet.js";
|
2020-11-14 23:24:01 +01:00
|
|
|
import { RdDActorEntiteSheet } from "./actor-entite-sheet.js";
|
2020-06-07 23:16:50 +02:00
|
|
|
import { RdDUtility } from "./rdd-utility.js";
|
2020-11-17 16:30:03 +01:00
|
|
|
import { TMRUtility } from "./tmr-utility.js";
|
2020-09-20 16:36:39 +02:00
|
|
|
import { RdDCalendrier } from "./rdd-calendrier.js";
|
2020-11-11 22:39:36 +01:00
|
|
|
import { RdDResolutionTable } from "./rdd-resolution-table.js";
|
2020-12-05 00:04:40 +01:00
|
|
|
import { RdDTokenHud } from "./rdd-token-hud.js";
|
2020-12-29 00:11:58 +01:00
|
|
|
import { RdDCommands } from "./rdd-commands.js";
|
2021-02-09 09:18:52 +01:00
|
|
|
import { RdDCombatManager, RdDCombat } from "./rdd-combat.js";
|
2021-01-07 00:32:22 +01:00
|
|
|
import { ChatUtility } from "./chat-utility.js";
|
2022-11-06 21:39:03 +01:00
|
|
|
import { StatusEffects } from "./settings/status-effects.js";
|
2021-01-26 00:25:41 +01:00
|
|
|
import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js";
|
2022-11-06 21:39:03 +01:00
|
|
|
import { ReglesOptionelles } from "./settings/regles-optionelles.js";
|
2021-01-29 15:13:59 +01:00
|
|
|
import { TMRRencontres } from "./tmr-rencontres.js";
|
2021-02-08 22:51:31 +01:00
|
|
|
import { RdDHotbar } from "./rdd-hotbar-drop.js"
|
2021-02-11 02:48:27 +01:00
|
|
|
import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
|
2021-04-04 18:37:16 +02:00
|
|
|
import { RdDHerbes } from "./rdd-herbes.js";
|
2021-04-06 23:36:35 +02:00
|
|
|
import { RdDItem } from "./item.js";
|
2021-04-29 02:57:56 +02:00
|
|
|
import { RdDDice } from "./rdd-dice.js";
|
2021-11-11 09:18:25 +01:00
|
|
|
import { RdDPossession } from "./rdd-possession.js";
|
2021-05-10 19:17:31 +02:00
|
|
|
import { RdDSigneDraconiqueItemSheet } from "./item-signedraconique-sheet.js";
|
2021-11-26 00:45:21 +01:00
|
|
|
import { Misc } from "./misc.js";
|
2022-09-17 16:07:38 +02:00
|
|
|
import { Migrations } from './migrations.js';
|
2022-11-04 20:41:16 +01:00
|
|
|
import { DialogChronologie } from "./dialog-chronologie.js";
|
2022-11-06 21:39:47 +01:00
|
|
|
import { SystemCompendiums } from "./settings/system-compendiums.js";
|
2022-11-05 18:19:53 +01:00
|
|
|
import { RdDRencontreItemSheet } from "./item-rencontre-sheet.js";
|
2020-06-07 23:16:50 +02:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2020-09-02 22:00:35 +02:00
|
|
|
|
|
|
|
/************************************************************************************/
|
2021-01-10 00:30:37 +01:00
|
|
|
Hooks.once("init", async function () {
|
2020-06-07 23:16:50 +02:00
|
|
|
console.log(`Initializing Reve de Dragon System`);
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2020-06-07 23:16:50 +02:00
|
|
|
// preload handlebars templates
|
|
|
|
RdDUtility.preloadHandlebarsTemplates();
|
2020-11-12 23:50:37 +01:00
|
|
|
// Create useful storage space
|
2021-01-29 15:13:59 +01:00
|
|
|
game.system.rdd = {
|
|
|
|
TMRUtility,
|
2021-02-08 22:51:31 +01:00
|
|
|
RdDUtility,
|
2021-11-11 09:18:25 +01:00
|
|
|
RdDHotbar,
|
|
|
|
RdDPossession,
|
2021-01-29 15:13:59 +01:00
|
|
|
}
|
2020-12-08 21:40:41 +01:00
|
|
|
|
2021-01-10 00:30:37 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
2020-12-01 17:36:13 +01:00
|
|
|
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"
|
|
|
|
});
|
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "calendrier", {
|
2021-01-10 00:30:37 +01:00
|
|
|
name: "calendrier",
|
2020-12-12 21:58:44 +01:00
|
|
|
scope: "world",
|
|
|
|
config: false,
|
2022-11-04 20:41:16 +01:00
|
|
|
default: RdDCalendrier.createCalendrierInitial(),
|
2020-12-12 21:58:44 +01:00
|
|
|
type: Object
|
|
|
|
});
|
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:01 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "migration-png-webp-1.5.34", {
|
|
|
|
name: "calendrier",
|
|
|
|
scope: "world",
|
|
|
|
config: false,
|
|
|
|
default: false,
|
|
|
|
type: Boolean
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
2021-01-10 00:30:37 +01:00
|
|
|
name: "liste-nombre-astral",
|
2020-12-08 23:12:43 +01:00
|
|
|
scope: "world",
|
|
|
|
config: false,
|
2021-06-08 14:09:40 +02:00
|
|
|
default: [],
|
2020-12-08 23:12:43 +01:00
|
|
|
type: Object
|
2020-12-12 21:58:44 +01:00
|
|
|
});
|
|
|
|
|
2020-12-08 23:12:43 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "calendrier-pos", {
|
2021-01-10 00:30:37 +01:00
|
|
|
name: "calendrierPos",
|
2021-06-08 14:11:23 +02:00
|
|
|
scope: "client",
|
2020-12-08 21:40:41 +01:00
|
|
|
config: false,
|
2021-06-08 14:11:23 +02:00
|
|
|
default: RdDCalendrier.createCalendrierPos(),
|
2020-12-08 21:40:41 +01:00
|
|
|
type: Object
|
2020-12-12 21:58:44 +01:00
|
|
|
});
|
2022-11-04 20:41:16 +01:00
|
|
|
|
|
|
|
|
2021-01-07 01:54:38 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", {
|
2021-01-07 01:54:38 +01:00
|
|
|
name: "Supprimer les dialogues de combat",
|
|
|
|
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
|
|
|
|
scope: "world",
|
|
|
|
config: true,
|
|
|
|
default: true,
|
|
|
|
type: Boolean
|
2021-01-10 00:30:37 +01:00
|
|
|
});
|
2021-01-12 20:58:30 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "activer-sons-audio", {
|
2021-01-12 20:58:30 +01:00
|
|
|
name: "Activer les bruitages intégrés",
|
|
|
|
hint: "Si activé, certaines actions en jeu déclenchent un son d'ambiance",
|
|
|
|
scope: "world",
|
|
|
|
config: true,
|
|
|
|
default: true,
|
|
|
|
type: Boolean
|
2021-05-10 18:39:35 +02:00
|
|
|
});
|
2021-04-06 23:44:57 +02:00
|
|
|
/* -------------------------------------------- */
|
2021-11-11 02:43:38 +01:00
|
|
|
game.settings.register(SYSTEM_RDD, "appliquer-famine-soif", {
|
2021-04-06 23:44:57 +02:00
|
|
|
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",
|
|
|
|
scope: "world",
|
|
|
|
config: true,
|
|
|
|
type: String,
|
|
|
|
choices: {
|
|
|
|
"aucun": "ni la famine, ni la soif",
|
|
|
|
"famine": "seulement la famine",
|
|
|
|
"famine-soif": "la famine et la soif",
|
|
|
|
},
|
|
|
|
default: "aucun"
|
2021-05-10 18:39:35 +02:00
|
|
|
});
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-10 00:30:37 +01:00
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
2021-01-13 11:35:36 +01:00
|
|
|
formula: "1+(1d6/10)",
|
|
|
|
decimals: 2
|
2020-06-07 23:16:50 +02:00
|
|
|
};
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-10-21 02:46:29 +02:00
|
|
|
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
|
2021-05-27 01:18:21 +02:00
|
|
|
console.log(">>>>> MSG RECV", sockmsg);
|
2022-10-07 23:30:06 +02:00
|
|
|
try {
|
|
|
|
RdDUtility.onSocketMessage(sockmsg);
|
|
|
|
RdDCombat.onSocketMessage(sockmsg);
|
|
|
|
ChatUtility.onSocketMessage(sockmsg);
|
|
|
|
RdDActor.onSocketMessage(sockmsg);
|
|
|
|
} catch(e) {
|
|
|
|
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg,' => ', e)
|
|
|
|
}
|
2020-06-17 20:31:43 +02:00
|
|
|
});
|
2020-06-07 23:16:50 +02:00
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-10 00:30:37 +01:00
|
|
|
// Define custom Entity classes
|
2021-03-25 03:18:27 +01:00
|
|
|
CONFIG.Actor.documentClass = RdDActor;
|
2021-04-06 23:36:35 +02:00
|
|
|
CONFIG.Item.documentClass = RdDItem;
|
2021-01-10 00:30:37 +01:00
|
|
|
CONFIG.RDD = {
|
|
|
|
resolutionTable: RdDResolutionTable.resolutionTable,
|
|
|
|
carac_array: RdDUtility.getCaracArray(),
|
|
|
|
ajustementsConditions: RdDUtility.getAjustementsConditions(),
|
|
|
|
difficultesLibres: RdDUtility.getDifficultesLibres()
|
2020-11-11 22:39:36 +01:00
|
|
|
}
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
2020-06-07 23:16:50 +02:00
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
2021-11-11 02:43:38 +01:00
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true });
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
2020-06-07 23:16:50 +02:00
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
2021-11-11 02:43:38 +01:00
|
|
|
Items.registerSheet(SYSTEM_RDD, RdDSigneDraconiqueItemSheet, {
|
2021-05-10 19:17:31 +02:00
|
|
|
label: "Signe draconique",
|
|
|
|
types: ["signedraconique"],
|
|
|
|
makeDefault: true
|
|
|
|
});
|
2022-11-05 18:19:53 +01:00
|
|
|
Items.registerSheet(SYSTEM_RDD, RdDRencontreItemSheet, {
|
|
|
|
label: "Rencontre",
|
|
|
|
types: ["rencontre"],
|
|
|
|
makeDefault: true
|
|
|
|
});
|
2021-11-11 02:43:38 +01:00
|
|
|
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
|
2022-11-05 18:19:53 +01:00
|
|
|
types: [
|
|
|
|
"competence", "competencecreature",
|
|
|
|
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
|
|
|
"objet", "arme", "armure", "conteneur", "herbe", "ingredient", "livre", "potion", "munition",
|
|
|
|
"monnaie", "nourritureboisson", "gemme",
|
|
|
|
"meditation", "rencontresTMR", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
|
|
|
"nombreastral", "tache", "maladie", "poison", "possession",
|
|
|
|
"tarot"
|
|
|
|
], makeDefault: true
|
2021-11-11 02:43:38 +01:00
|
|
|
});
|
2021-03-25 03:18:27 +01:00
|
|
|
CONFIG.Combat.documentClass = RdDCombatManager;
|
2020-09-02 22:00:35 +02:00
|
|
|
|
2021-01-10 00:30:37 +01:00
|
|
|
// préparation des différents modules
|
2022-11-06 21:39:47 +01:00
|
|
|
SystemCompendiums.init();
|
2022-11-05 18:06:30 +01:00
|
|
|
DialogChronologie.init();
|
2021-05-08 20:08:56 +02:00
|
|
|
ReglesOptionelles.init();
|
2021-03-29 23:41:08 +02:00
|
|
|
RdDUtility.init();
|
2021-04-29 02:57:56 +02:00
|
|
|
RdDDice.init();
|
2021-01-10 00:30:37 +01:00
|
|
|
RdDCommands.init();
|
|
|
|
RdDCombat.init();
|
2021-05-10 18:39:35 +02:00
|
|
|
RdDCombatManager.init();
|
2021-01-10 00:30:37 +01:00
|
|
|
RdDTokenHud.init();
|
2021-01-13 03:42:13 +01:00
|
|
|
RdDActor.init();
|
2021-01-26 00:25:41 +01:00
|
|
|
RddCompendiumOrganiser.init();
|
2021-02-11 02:48:27 +01:00
|
|
|
EffetsDraconiques.init()
|
2021-01-29 15:13:59 +01:00
|
|
|
TMRUtility.init();
|
|
|
|
TMRRencontres.init();
|
2021-02-08 22:51:31 +01:00
|
|
|
RdDHotbar.initDropbar();
|
2021-11-11 09:18:25 +01:00
|
|
|
RdDPossession.init();
|
2020-07-21 23:51:24 +02:00
|
|
|
});
|
|
|
|
|
2020-12-04 10:15:55 +01:00
|
|
|
/* -------------------------------------------- */
|
2021-01-10 00:30:37 +01:00
|
|
|
function messageDeBienvenue() {
|
2021-01-20 00:44:19 +01:00
|
|
|
if (game.user.isGM) {
|
|
|
|
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">');
|
|
|
|
ChatMessage.create({
|
2021-03-25 03:18:27 +01:00
|
|
|
user: game.user.id,
|
2021-01-20 00:44:19 +01:00
|
|
|
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>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
|
|
|
` });
|
2021-01-22 02:00:04 +01:00
|
|
|
}
|
2020-11-23 19:51:34 +01:00
|
|
|
}
|
2021-05-10 18:39:35 +02:00
|
|
|
|
2022-01-30 16:11:20 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register world usage statistics
|
|
|
|
function registerUsageCount( registerKey ) {
|
|
|
|
if ( game.user.isGM ) {
|
2022-06-12 13:58:55 +02:00
|
|
|
game.settings.register("world", "world-key", {
|
2022-01-30 16:11:20 +01:00
|
|
|
name: "Unique world key",
|
|
|
|
scope: "world",
|
|
|
|
config: false,
|
2022-06-12 13:58:55 +02:00
|
|
|
default: "NONE",
|
2022-01-30 16:11:20 +01:00
|
|
|
type: String
|
|
|
|
});
|
|
|
|
|
2022-06-12 13:58:55 +02:00
|
|
|
let worldKey = game.settings.get("world", "world-key")
|
2022-01-30 16:11:20 +01:00
|
|
|
if ( worldKey == undefined || worldKey == "" ) {
|
|
|
|
worldKey = randomID(32)
|
2022-06-12 13:58:55 +02:00
|
|
|
game.settings.set("world", "world-key", worldKey )
|
2022-01-30 16:11:20 +01:00
|
|
|
}
|
2022-06-12 13:58:55 +02:00
|
|
|
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}"`
|
2022-03-02 20:19:02 +01:00
|
|
|
$.ajax(regURL)
|
2022-01-30 16:11:20 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-07 00:01:07 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
2021-06-05 20:53:43 +02:00
|
|
|
Hooks.once("ready", async function () {
|
2021-11-11 02:43:01 +01:00
|
|
|
await migrationPngWebp_1_5_34()
|
2022-09-17 16:07:38 +02:00
|
|
|
if (Misc.isUniqueConnectedGM()) {
|
|
|
|
new Migrations().migrate();
|
|
|
|
}
|
2021-05-10 18:39:35 +02:00
|
|
|
|
2021-01-22 02:00:04 +01:00
|
|
|
StatusEffects.onReady();
|
2021-04-04 18:37:16 +02:00
|
|
|
RdDHerbes.initializeHerbes();
|
2021-06-02 16:14:41 +02:00
|
|
|
RdDDice.onReady();
|
2020-12-08 21:40:41 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* 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 => {
|
2020-09-20 16:36:39 +02:00
|
|
|
calendrier.render(true);
|
2021-01-10 00:30:37 +01:00
|
|
|
});
|
2020-12-08 21:40:41 +01:00
|
|
|
game.system.rdd.calendrier = calendrier; // Reference;
|
|
|
|
|
2020-12-04 10:15:55 +01:00
|
|
|
// Avertissement si joueur sans personnage
|
2021-01-10 00:30:37 +01:00
|
|
|
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 !",
|
2021-03-25 03:18:27 +01:00
|
|
|
user: game.user.id
|
2021-01-10 00:30:37 +01:00
|
|
|
});
|
2020-12-04 10:15:55 +01:00
|
|
|
}
|
2021-11-26 00:45:21 +01:00
|
|
|
if (Misc.isUniqueConnectedGM()) {
|
2021-11-11 02:43:01 +01:00
|
|
|
messageDeBienvenue();
|
2022-06-12 08:17:59 +02:00
|
|
|
registerUsageCount( SYSTEM_RDD );
|
2021-11-11 02:43:01 +01:00
|
|
|
}
|
2020-09-20 16:36:39 +02:00
|
|
|
});
|
2020-07-24 10:51:11 +02:00
|
|
|
|
2021-11-11 02:43:01 +01:00
|
|
|
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) {
|
2021-11-11 09:25:38 +01:00
|
|
|
return documents.filter(it => it.img && it.img.match(regexOldPngJpg))
|
2021-11-11 02:43:01 +01:00
|
|
|
.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 => {
|
2022-09-07 09:01:23 +02:00
|
|
|
if (actor.token?.img && actor.token.img.match(regexOldPngJpg)) {
|
|
|
|
actor.update({ "token.img": convertImgToWebp(actor.token.img) });
|
2021-11-11 02:43:01 +01:00
|
|
|
}
|
|
|
|
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
|
|
|
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
|
|
|
});
|
|
|
|
game.settings.set(SYSTEM_RDD, "migration-png-webp-1.5.34", true)
|
|
|
|
}
|
2021-12-20 10:18:28 +01:00
|
|
|
|
|
|
|
// CSS patch for v9
|
|
|
|
if (game.version) {
|
|
|
|
let sidebar = document.getElementById("sidebar");
|
|
|
|
sidebar.style.width = "min-content";
|
|
|
|
}
|
2022-01-30 16:11:20 +01:00
|
|
|
|
2021-11-11 02:43:01 +01:00
|
|
|
}
|
|
|
|
|
2020-07-21 23:51:24 +02:00
|
|
|
/* -------------------------------------------- */
|
2021-04-29 02:57:56 +02:00
|
|
|
/* Dice-so-nice ready */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d));
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT chat message */
|
2020-07-21 23:51:24 +02:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
2020-12-29 00:11:58 +01:00
|
|
|
if (content[0] == '/') {
|
|
|
|
let regExp = /(\S+)/g;
|
2021-11-27 00:04:34 +01:00
|
|
|
let commands = content.match(regExp);
|
2021-01-10 00:30:37 +01:00
|
|
|
if (game.system.rdd.commands.processChatCommand(commands, content, msg)) {
|
2020-12-29 00:11:58 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
2020-11-24 16:41:15 +01:00
|
|
|
|