2021-01-17 22:09:01 +01:00
|
|
|
/**
|
|
|
|
* RdD system
|
|
|
|
* Author: LeRatierBretonnien
|
|
|
|
* Software License: GNU GPLv3
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Import Modules
|
|
|
|
import { SoSActor } from "./actor.js";
|
|
|
|
import { SoSItemSheet } from "./item-sheet.js";
|
|
|
|
import { SoSActorSheet } from "./actor-sheet.js";
|
2021-01-18 17:46:39 +01:00
|
|
|
import { SoSUtility } from "./sos-utility.js";
|
2021-01-17 22:09:01 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
const _patch_initiative = () => {
|
|
|
|
Combat.prototype.rollInitiative = async function (
|
|
|
|
ids,
|
|
|
|
formula = undefined,
|
|
|
|
messageOptions = {}
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
Hooks.once("init", async function () {
|
|
|
|
console.log(`Initializing Shadows over Sol System`);
|
|
|
|
|
|
|
|
// preload handlebars templates
|
|
|
|
SoSUtility.preloadHandlebarsTemplates();
|
|
|
|
// Create useful storage space
|
2021-01-18 17:46:39 +01:00
|
|
|
game.system.sos = { }
|
2021-01-17 22:09:01 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
|
|
|
formula: "1+(1d6/10)",
|
|
|
|
decimals: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.socket.on("system.foundryvtt-shadows-over-sol", data => {
|
|
|
|
SoSUtility.onSocketMesssage(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Actor.entityClass = SoSActor;
|
|
|
|
CONFIG.SoS = {
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
2021-01-18 17:46:39 +01:00
|
|
|
Actors.registerSheet("foundryvtt-shadows-over-sol", SoSActorSheet, { types: ["character"], makeDefault: true });
|
2021-01-17 22:09:01 +01:00
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
2021-01-18 17:46:39 +01:00
|
|
|
Items.registerSheet("foundryvtt-shadows-over-sol", SoSItemSheet, { makeDefault: true });
|
2021-01-17 22:09:01 +01:00
|
|
|
|
|
|
|
// Patch the initiative formula
|
|
|
|
_patch_initiative();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
function welcomeMessage() {
|
2021-01-18 17:46:39 +01:00
|
|
|
//ChatUtility.removeMyChatMessageContaining('<div id="welcome-message-sos">');
|
2021-01-17 22:09:01 +01:00
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user._id,
|
|
|
|
whisper: [game.user._id],
|
|
|
|
content: `<div id="welcome-message-sos"><span class="rdd-roll-part">Welcome !</div>
|
|
|
|
` });
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.once("ready", function () {
|
|
|
|
|
|
|
|
// User warning
|
|
|
|
if (!game.user.isGM && game.user.character == undefined) {
|
|
|
|
ui.notifications.info("Warning ! You are not linked to any actor !");
|
|
|
|
ChatMessage.create({
|
|
|
|
content: "<b>WARNING</b> Player " + game.user.name + " is not linked to an actor !",
|
|
|
|
user: game.user._id
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
welcomeMessage();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
|
|
if (content[0] == '/') {
|
|
|
|
let regExp = /(\S+)/g;
|
|
|
|
let commands = content.toLowerCase().match(regExp);
|
|
|
|
if (game.system.sos.commands.processChatCommand(commands, content, msg)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("getCombatTrackerEntryContext", (html, options) => {
|
2021-01-18 17:46:39 +01:00
|
|
|
//SoS.pushInitiativeOptions(html, options);
|
2021-01-17 22:09:01 +01:00
|
|
|
}
|
|
|
|
)
|