foundryvtt-shadows-over-sol/module/sos-main.js

134 lines
4.1 KiB
JavaScript
Raw Permalink Normal View History

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-02-03 15:33:07 +01:00
import { SoSCombat } from "./sos-combat.js";
2021-02-17 18:02:11 +01:00
import { gearConverter } from "./gears_convert.js";
2021-03-08 22:46:33 +01:00
import { SoSGMDeck } from "./sos-gm-deck.js";
2024-02-08 12:53:15 +01:00
import { ClassCounter} from "https://www.uberwald.me/fvtt_appcount/count-class-ready.js"
2021-01-17 22:09:01 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Shadows Over Sol System`);
2021-01-17 22:09:01 +01:00
2021-03-08 22:46:33 +01:00
/* -------------------------------------------- */
game.settings.register("foundryvtt-shadows-over-sol", "gmDeck", {
name: "gmDeck",
scope: "world",
config: false,
type: Object
});
/* -------------------------------------------- */
2021-01-17 22:09:01 +01:00
// preload handlebars templates
SoSUtility.preloadHandlebarsTemplates();
// Create useful storage space
2021-03-08 22:46:33 +01:00
let html = await renderTemplate('systems/foundryvtt-shadows-over-sol/templates/gm-deck.html', {} );
let gmDeck = new SoSGMDeck(html);
game.system.sos = {
gmDeck: gmDeck,
}
2021-01-17 22:09:01 +01:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
2021-02-04 08:38:59 +01:00
formula: "1d3",
2021-01-17 22:09:01 +01:00
decimals: 2
};
/* -------------------------------------------- */
game.socket.on("system.foundryvtt-shadows-over-sol", data => {
SoSUtility.onSocketMesssage(data);
});
/* -------------------------------------------- */
// Define custom Entity classes
2021-05-22 23:20:23 +02:00
CONFIG.Actor.documentClass = SoSActor;
CONFIG.Combat.documentClass = SoSCombat;
2021-01-17 22:09:01 +01:00
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
2021-02-03 15:33:07 +01:00
// Init/registers
Hooks.on('renderChatLog', (log, html, data) => {
SoSUtility.registerChatCallbacks(html);
});
2021-02-04 22:55:57 +01:00
// Init/registers
Hooks.on('updateCombat', (combat, round, diff, id) => {
SoSUtility.updateCombat(combat, round, diff, id);
});
2021-02-03 15:33:07 +01:00
2021-01-17 22:09:01 +01:00
});
/* -------------------------------------------- */
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({
2021-05-22 23:20:23 +02:00
user: game.user.id,
whisper: [game.user.id],
2021-01-17 22:09:01 +01:00
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
});
}
2024-02-08 12:53:15 +01:00
ClassCounter.registerUsageCount()
2021-01-17 22:09:01 +01:00
welcomeMessage();
});
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
let commands = content.toLowerCase().match(regExp);
2021-03-08 23:26:56 +01:00
console.log(commands);
if ( commands[0] == '/gmdeck') {
2021-03-08 23:42:38 +01:00
game.system.sos.gmDeck.render( true );
2021-01-17 22:09:01 +01:00
return false;
}
}
return true;
});
2021-03-08 23:26:56 +01:00
2021-01-17 22:09:01 +01:00
/* -------------------------------------------- */
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
}
)