fvtt-hero-system-6/modules/hero6-main.js

117 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

2022-12-15 21:44:23 +01:00
/**
* Hero6 system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { Hero6Actor } from "./hero6-actor.js";
import { Hero6ItemSheet } from "./hero6-item-sheet.js";
import { Hero6ActorSheet } from "./hero6-actor-sheet.js";
import { Hero6NPCSheet } from "./hero6-npc-sheet.js";
import { Hero6Utility } from "./hero6-utility.js";
2023-04-06 16:57:19 +02:00
import { Hero6Combat, Hero6CombatTracker } from "./hero6-combat.js";
2022-12-15 21:44:23 +01:00
import { Hero6Item } from "./hero6-item.js";
import { Hero6Hotbar } from "./hero6-hotbar.js"
import { Hero6Commands } from "./hero6-commands.js"
import { Hero6_CONFIG } from "./hero6-config.js";
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Hero6 RPG`);
2022-12-15 22:12:28 +01:00
game.system.hero6 = {
2022-12-15 21:44:23 +01:00
Hero6Commands,
config: Hero6_CONFIG
}
/* -------------------------------------------- */
// preload handlebars templates
Hero6Utility.preloadHandlebarsTemplates();
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
2023-04-06 16:57:19 +02:00
decimals: 3
2022-12-15 21:44:23 +01:00
};
2023-06-30 21:11:29 +02:00
/* ------------------------------- ------------- */
2022-12-15 21:44:23 +01:00
game.socket.on("system.fvtt-hero-system-6", data => {
Hero6Utility.onSocketMesssage(data)
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = Hero6Combat
CONFIG.Actor.documentClass = Hero6Actor
CONFIG.Item.documentClass = Hero6Item
2023-04-06 16:57:19 +02:00
CONFIG.ui.combat = Hero6CombatTracker;
2022-12-15 21:44:23 +01:00
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-hero-system-6", Hero6ActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("fvtt-hero-system-6", Hero6NPCSheet, { types: ["npc"], makeDefault: false });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-hero-system-6", Hero6ItemSheet, { makeDefault: true });
Hero6Utility.init()
});
/* -------------------------------------------- */
function welcomeMessage() {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-dark-stars"><span class="rdd-roll-part">
2023-07-06 13:10:41 +02:00
<strong>Welcome to Hero System 6E RPG.</strong>
2022-12-15 21:44:23 +01:00
` });
}
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
// 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
});
}
welcomeMessage();
Hero6Utility.ready()
2023-05-07 14:03:14 +02:00
Hero6Commands.ready()
2023-06-30 21:11:29 +02:00
Hero6Combat.ready()
2023-06-30 17:21:11 +02:00
2022-12-15 21:44:23 +01:00
})
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
let commands = content.match(regExp);
2022-12-15 22:12:28 +01:00
if (game.system.hero6.commands.processChatCommand(commands, content, msg)) {
2022-12-15 21:44:23 +01:00
return false;
}
}
return true;
});