fvtt-imperium5/modules/imperium5-main.js

111 lines
3.5 KiB
JavaScript
Raw Normal View History

2022-03-13 16:17:04 +01:00
/**
* imperium5 system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { Imperium5Actor } from "./imperium5-actor.js";
import { Imperium5ItemSheet } from "./imperium5-item-sheet.js";
import { Imperium5ActorSheet } from "./imperium5-actor-sheet.js";
2022-10-31 09:10:23 +01:00
import { Imperium5ActorPMSheet } from "./imperium5-actor-pm-sheet.js";
2022-03-13 16:17:04 +01:00
import { Imperium5Utility } from "./imperium5-utility.js";
import { Imperium5Combat } from "./imperium5-combat.js";
import { Imperium5Item } from "./imperium5-item.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
2022-03-19 09:30:00 +01:00
console.log(`Initializing Imperium5 RPG`);
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
// preload handlebars templates
2022-03-19 09:30:00 +01:00
Imperium5Utility.preloadHandlebarsTemplates();
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
2022-03-19 09:30:00 +01:00
game.socket.on("system.fvtt-imperium5", data => {
Imperium5Utility.onSocketMesssage(data)
2022-03-13 16:17:04 +01:00
});
/* -------------------------------------------- */
// Define custom Entity classes
2022-03-19 09:30:00 +01:00
CONFIG.Combat.documentClass = Imperium5Combat
CONFIG.Actor.documentClass = Imperium5Actor
CONFIG.Item.documentClass = Imperium5Item
game.system.imperium5 = { }
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
// Register sheet application classes
2022-03-19 09:30:00 +01:00
Actors.unregisterSheet("core", ActorSheet)
Actors.registerSheet("fvtt-imperium5", Imperium5ActorSheet, { types: ["character"], makeDefault: true })
2022-10-31 09:10:23 +01:00
Actors.registerSheet("fvtt-imperium5", Imperium5ActorPMSheet, { types: ["pm"], makeDefault: true })
2022-03-13 16:17:04 +01:00
2022-03-19 09:30:00 +01:00
Items.unregisterSheet("core", ItemSheet)
Items.registerSheet("fvtt-imperium5", Imperium5ItemSheet, { makeDefault: true } )
2022-03-13 16:17:04 +01:00
2022-03-19 09:30:00 +01:00
Imperium5Utility.init()
2022-03-13 16:17:04 +01:00
2022-03-19 09:30:00 +01:00
})
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
function welcomeMessage() {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-pegasus"><span class="rdd-roll-part">
2022-03-19 09:30:00 +01:00
<strong>Bienvenue dans Imperium5 !</strong>
2022-03-13 16:17:04 +01:00
` });
}
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
2022-03-19 09:30:00 +01:00
Imperium5Utility.ready()
2022-03-13 16:17:04 +01:00
if (!game.user.isGM && game.user.character == undefined) {
2022-03-19 09:30:00 +01:00
ui.notifications.info("Attention ! Aucun personnage n'est relié !")
2022-03-13 16:17:04 +01:00
ChatMessage.create({
2022-03-19 09:30:00 +01:00
content: "<b>WARNING</b> Le joueur " + game.user.name + " n'est pas connecté à un personnage !",
2022-03-13 16:17:04 +01:00
user: game.user._id
});
}
// CSS patch for v9
if (game.version) {
2022-03-19 09:30:00 +01:00
let sidebar = document.getElementById("sidebar")
sidebar.style.width = "min-content"
2022-03-13 16:17:04 +01:00
}
2022-10-21 09:38:43 +02:00
2022-03-19 09:30:00 +01:00
welcomeMessage()
})
2022-03-13 16:17:04 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
2022-03-19 09:30:00 +01:00
let regExp = /(\S+)/g
let commands = content.match(regExp)
if (game.system.imperium5.commands.processChatCommand(commands, content, msg)) {
return false
2022-03-13 16:17:04 +01:00
}
}
2022-03-19 09:30:00 +01:00
return true
2022-03-13 16:17:04 +01:00
});