foundryvtt-reve-de-dragon/module/rdd-main.js

99 lines
3.4 KiB
JavaScript
Raw Normal View History

2020-06-07 23:16:50 +02:00
/**
* RdD system
* Author: LeRatierBretonnien
* Software License: GNU GPLv3
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { RdDActor } from "./actor.js";
import { RdDItemSheet } from "./item-sheet.js";
import { RdDActorSheet } from "./actor-sheet.js";
import { RdDUtility } from "./rdd-utility.js";
2020-07-21 23:51:24 +02:00
import { TMRUtility } from "./tmr-utility.js";
2020-06-07 23:16:50 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("init", async function() {
console.log(`Initializing Reve de Dragon System`);
// preload handlebars templates
RdDUtility.preloadHandlebarsTemplates();
2020-08-13 22:28:56 +02:00
// Create specific settings
game.settings.register("foundryvtt-reve-de-dragon", "configuration", {
name: "configuration",
scope: "world",
config: false,
type: Object
});
//game.settings.get("<systemName>","<settingName>") to retrieve it and game.settings.set("<systemName>","<settingName>", <newValue>)
2020-06-07 23:16:50 +02:00
/**
* Set an initiative formula for the system
* @type {String}
*/
CONFIG.Combat.initiative = {
formula: "1d20",
decimals: 2
};
2020-06-17 20:31:43 +02:00
game.socket.on("system.foundryvtt-reve-de-dragon", data => {
RdDUtility.performSocketMesssage( data );
});
2020-06-07 23:16:50 +02:00
// Define custom Entity classes
CONFIG.Actor.entityClass = RdDActor;
CONFIG.RDD = {}
CONFIG.RDD.resolutionTable = RdDUtility.buildResolutionTable();
CONFIG.RDD.level_category = RdDUtility.getLevelCategory();
CONFIG.RDD.carac_array = RdDUtility.getCaracArray();
CONFIG.RDD.bonusmalus = RdDUtility.getBonusMalus();
game.data.RdDUtility = RdDUtility;
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true});
2020-07-21 23:51:24 +02:00
});
2020-07-24 10:51:11 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function() {
ChatMessage.create( { title: "Bienvenu dans le Rêve !", content : "Bienvenu dans le Rêve des Dragons !<br> " +
"Vous trouverez quelques infos pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}" } );
} );
2020-07-21 23:51:24 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
const table2func = { "queues": TMRUtility.getQueue, "ombre": TMRUtility.getOmbre, "tetehr": TMRUtility.getTeteHR, "tete": TMRUtility.getTete, "souffle": TMRUtility.getSouffle };
Hooks.on("chatMessage", (html, content, msg) => {
2020-06-07 23:16:50 +02:00
2020-07-21 23:51:24 +02:00
// Setup new message's visibility
let rollMode = game.settings.get("core", "rollMode");
if (["gmroll", "blindroll"].includes(rollMode)) msg["whisper"] = ChatMessage.getWhisperIDs("GM");
if (rollMode === "blindroll") msg["blind"] = true;
msg["type"] = 0;
2020-06-07 23:16:50 +02:00
2020-07-21 23:51:24 +02:00
let regExp;
regExp = /(\S+)/g;
let commands = content.match(regExp);
let command = commands[0];
2020-06-07 23:16:50 +02:00
2020-07-21 23:51:24 +02:00
// Roll on a table
if (command === "/table") {
let tableName = commands[1].toLowerCase();
table2func[tableName]();
return false
}
return true;
} );