109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
/**
|
|
* 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";
|
|
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 () {
|
|
console.log(`Initializing Imperium5 RPG`);
|
|
|
|
/* -------------------------------------------- */
|
|
// preload handlebars templates
|
|
Imperium5Utility.preloadHandlebarsTemplates();
|
|
|
|
/* -------------------------------------------- */
|
|
// Set an initiative formula for the system
|
|
CONFIG.Combat.initiative = {
|
|
formula: "1d6",
|
|
decimals: 1
|
|
};
|
|
|
|
/* -------------------------------------------- */
|
|
game.socket.on("system.fvtt-imperium5", data => {
|
|
Imperium5Utility.onSocketMesssage(data)
|
|
});
|
|
|
|
/* -------------------------------------------- */
|
|
// Define custom Entity classes
|
|
CONFIG.Combat.documentClass = Imperium5Combat
|
|
CONFIG.Actor.documentClass = Imperium5Actor
|
|
CONFIG.Item.documentClass = Imperium5Item
|
|
game.system.imperium5 = { }
|
|
|
|
/* -------------------------------------------- */
|
|
// Register sheet application classes
|
|
Actors.unregisterSheet("core", ActorSheet)
|
|
Actors.registerSheet("fvtt-imperium5", Imperium5ActorSheet, { types: ["character"], makeDefault: true })
|
|
|
|
Items.unregisterSheet("core", ItemSheet)
|
|
Items.registerSheet("fvtt-imperium5", Imperium5ItemSheet, { makeDefault: true } )
|
|
|
|
Imperium5Utility.init()
|
|
|
|
})
|
|
|
|
/* -------------------------------------------- */
|
|
function welcomeMessage() {
|
|
ChatMessage.create({
|
|
user: game.user.id,
|
|
whisper: [game.user.id],
|
|
content: `<div id="welcome-message-pegasus"><span class="rdd-roll-part">
|
|
<strong>Bienvenue dans Imperium5 !</strong>
|
|
` });
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/* Foundry VTT Initialization */
|
|
/* -------------------------------------------- */
|
|
Hooks.once("ready", function () {
|
|
|
|
Imperium5Utility.ready()
|
|
|
|
if (!game.user.isGM && game.user.character == undefined) {
|
|
ui.notifications.info("Attention ! Aucun personnage n'est relié !")
|
|
ChatMessage.create({
|
|
content: "<b>WARNING</b> Le joueur " + game.user.name + " n'est pas connecté à un personnage !",
|
|
user: game.user._id
|
|
});
|
|
}
|
|
|
|
// CSS patch for v9
|
|
if (game.version) {
|
|
let sidebar = document.getElementById("sidebar")
|
|
sidebar.style.width = "min-content"
|
|
}
|
|
|
|
welcomeMessage()
|
|
})
|
|
|
|
/* -------------------------------------------- */
|
|
/* Foundry VTT Initialization */
|
|
/* -------------------------------------------- */
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
if (content[0] == '/') {
|
|
let regExp = /(\S+)/g
|
|
let commands = content.match(regExp)
|
|
if (game.system.imperium5.commands.processChatCommand(commands, content, msg)) {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
});
|
|
|