Init
This commit is contained in:
111
modules/mournblade-main.js
Normal file
111
modules/mournblade-main.js
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
* Mournblade system
|
||||
* Author: Uberwald
|
||||
* Software License: Prop
|
||||
*/
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Import Modules
|
||||
import { MournbladeActor } from "./mournblade-actor.js";
|
||||
import { MournbladeItemSheet } from "./mournblade-item-sheet.js";
|
||||
import { MournbladeActorSheet } from "./mournblade-actor-sheet.js";
|
||||
import { MournbladeNPCSheet } from "./mournblade-npc-sheet.js";
|
||||
import { MournbladeUtility } from "./mournblade-utility.js";
|
||||
import { MournbladeCombat } from "./mournblade-combat.js";
|
||||
import { MournbladeItem } from "./mournblade-item.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/************************************************************************************/
|
||||
Hooks.once("init", async function () {
|
||||
console.log(`Initializing Mournblade RPG`);
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// preload handlebars templates
|
||||
MournbladeUtility.preloadHandlebarsTemplates();
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Set an initiative formula for the system
|
||||
CONFIG.Combat.initiative = {
|
||||
formula: "1d6",
|
||||
decimals: 1
|
||||
};
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.socket.on("system.fvtt-mournblade-rpg", data => {
|
||||
MournbladeUtility.onSocketMesssage(data);
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Define custom Entity classes
|
||||
CONFIG.Combat.documentClass = MournbladeCombat
|
||||
CONFIG.Actor.documentClass = MournbladeActor
|
||||
CONFIG.Item.documentClass = MournbladeItem
|
||||
//CONFIG.Token.objectClass = MournbladeToken
|
||||
game.system.Mournblade = { };
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("fvtt-mournblade", MournbladeActorSheet, { types: ["character"], makeDefault: true });
|
||||
Actors.registerSheet("fvtt-mournblade", MournbladeNPCSheet, { types: ["npc"], makeDefault: false });
|
||||
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("fvtt-mournblade", MournbladeItemSheet, { makeDefault: true });
|
||||
|
||||
MournbladeUtility.init();
|
||||
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
function welcomeMessage() {
|
||||
ChatMessage.create({
|
||||
user: game.user.id,
|
||||
whisper: [game.user.id],
|
||||
content: `<div id="welcome-message-Mournblade"><span class="rdd-roll-part">
|
||||
<strong>Welcome to Mournblade RPG.</strong>
|
||||
` });
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
Hooks.once("ready", function () {
|
||||
|
||||
MournbladeUtility.ready();
|
||||
// User warning
|
||||
if (!game.user.isGM && game.user.character == undefined) {
|
||||
ui.notifications.info("Warning ! No character linked to your user !");
|
||||
ChatMessage.create({
|
||||
content: "<b>WARNING</b> The player " + game.user.name + " is not linked to a character !",
|
||||
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.Mournblade.commands.processChatCommand(commands, content, msg)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
Reference in New Issue
Block a user