fvtt-ecryme/modules/ecryme-main.js

139 lines
4.5 KiB
JavaScript
Raw Normal View History

2023-04-19 18:44:41 +02:00
/**
* Ecryme system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { EcrymeActor } from "./actors/ecryme-actor.js";
import { EcrymeItemSheet } from "./items/ecryme-item-sheet.js";
import { EcrymeActorSheet } from "./actors/ecryme-actor-sheet.js";
2023-08-08 14:54:39 +02:00
import { EcrymeAnnencySheet } from "./actors/ecryme-annency-sheet.js";
2023-04-19 18:44:41 +02:00
import { EcrymeUtility } from "./common/ecryme-utility.js";
import { EcrymeCombat } from "./app/ecryme-combat.js";
import { EcrymeItem } from "./items/ecryme-item.js";
import { EcrymeHotbar } from "./app/ecryme-hotbar.js"
import { EcrymeCharacterSummary } from "./app/ecryme-summary-app.js"
2023-04-28 15:25:57 +02:00
import { ECRYME_CONFIG } from "./common/ecryme-config.js"
2023-04-19 18:44:41 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Ecryme RPG`);
game.system.ecryme = {
config: ECRYME_CONFIG,
EcrymeHotbar
}
/* -------------------------------------------- */
// preload handlebars templates
EcrymeUtility.preloadHandlebarsTemplates();
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
game.socket.on("system.fvtt-ecryme", data => {
EcrymeUtility.onSocketMesssage(data)
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = EcrymeCombat
CONFIG.Actor.documentClass = EcrymeActor
CONFIG.Item.documentClass = EcrymeItem
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
2023-04-28 15:25:57 +02:00
Actors.registerSheet("fvtt-ecryme", EcrymeActorSheet, { types: ["pc"], makeDefault: true });
2023-08-09 20:44:25 +02:00
Actors.registerSheet("fvtt-ecryme", EcrymeActorSheet, { types: ["npc"], makeDefault: true });
2023-08-08 14:54:39 +02:00
Actors.registerSheet("fvtt-ecryme", EcrymeAnnencySheet, { types: ["annency"], makeDefault: false });
2023-04-19 18:44:41 +02:00
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-ecryme", EcrymeItemSheet, { makeDefault: true });
EcrymeUtility.init()
Babele.get().setSystemTranslationsDir("translated")
2023-07-29 09:44:29 +02:00
2023-04-19 18:44:41 +02:00
});
/* -------------------------------------------- */
function welcomeMessage() {
if (game.user.isGM) {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-ecryme"><span class="rdd-roll-part">
2023-05-03 20:05:31 +02:00
<strong>Bienvenu dans Ecryme !</strong>` });
2023-04-19 18:44:41 +02:00
}
}
2023-05-03 20:05:31 +02:00
2024-03-15 12:10:44 +01:00
/* -------------------------------------------- */
async function importDefaultScene() {
let exists = game.scenes.find(j => j.name == "Landing page 1");
if (!exists) {
const scenes = await EcrymeUtility.loadCompendium("fvtt-ecryme.scenes")
let newDocuments = scenes.filter(i => i.name == "Landing page 1");
await game.scenes.documentClass.create(newDocuments);
game.scenes.find(i => i.name == "Landing page 1").activate();
}
}
2023-04-19 18:44:41 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
// User warning
if (!game.user.isGM && game.user.character == undefined) {
ui.notifications.info("Attention ! Aucun personnage relié au joueur !");
ChatMessage.create({
content: "<b>WARNING</b> Le joueur " + game.user.name + " n'est pas relié à un personnage !",
user: game.user._id
});
}
2024-03-15 12:10:44 +01:00
import("https://www.uberwald.me/fvtt_appcount/count-class-ready.js").then(moduleCounter=>{
console.log("ClassCounter loaded", moduleCounter)
moduleCounter.ClassCounter.registerUsageCount()
}).catch(err=>
console.log("No stats available, giving up.")
)
2023-04-19 18:44:41 +02:00
welcomeMessage();
2024-03-15 12:10:44 +01:00
EcrymeUtility.ready();
EcrymeCharacterSummary.ready();
importDefaultScene();
2023-04-19 18:44:41 +02:00
})
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
let commands = content.match(regExp);
if (game.system.ecryme.commands.processChatCommand(commands, content, msg)) {
return false;
}
}
return true;
});