fvtt-dark-stars/modules/dark-stars-main.js

116 lines
3.8 KiB
JavaScript
Raw Permalink Normal View History

2022-11-27 08:58:19 +01:00
/**
* DarkStars system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { DarkStarsActor } from "./dark-stars-actor.js";
import { DarkStarsItemSheet } from "./dark-stars-item-sheet.js";
import { DarkStarsActorSheet } from "./dark-stars-actor-sheet.js";
import { DarkStarsNPCSheet } from "./dark-stars-npc-sheet.js";
import { DarkStarsUtility } from "./dark-stars-utility.js";
import { DarkStarsCombat } from "./dark-stars-combat.js";
import { DarkStarsItem } from "./dark-stars-item.js";
2022-12-04 12:16:25 +01:00
import { DarkStarsHotbar } from "./dark-stars-hotbar.js"
2022-11-27 08:58:19 +01:00
import { DarkStarsCommands } from "./dark-stars-commands.js"
2022-12-04 12:16:25 +01:00
import { DARKSTARS_CONFIG } from "./dark-stars-config.js";
2024-02-08 13:03:06 +01:00
import { ClassCounter} from "https://www.uberwald.me/fvtt_appcount/count-class-ready.js"
2022-11-27 08:58:19 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing DarkStars RPG`);
game.system.darkstars = {
2022-12-04 12:16:25 +01:00
DarkStarsCommands,
config: DARKSTARS_CONFIG
2022-11-27 08:58:19 +01:00
}
/* -------------------------------------------- */
// preload handlebars templates
DarkStarsUtility.preloadHandlebarsTemplates();
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
game.socket.on("system.fvtt-dark-stars", data => {
DarkStarsUtility.onSocketMesssage(data)
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = DarkStarsCombat
CONFIG.Actor.documentClass = DarkStarsActor
CONFIG.Item.documentClass = DarkStarsItem
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-dark-stars", DarkStarsActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("fvtt-dark-stars", DarkStarsNPCSheet, { types: ["npc"], makeDefault: false });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-dark-stars", DarkStarsItemSheet, { makeDefault: true });
DarkStarsUtility.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">
<strong>Welcome to the DarkStars RPG.</strong>
` });
}
/* -------------------------------------------- */
/* 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
});
}
2024-01-26 08:45:59 +01:00
2022-11-27 08:58:19 +01:00
welcomeMessage();
DarkStarsUtility.ready()
DarkStarsCommands.init()
2024-02-08 13:03:06 +01:00
ClassCounter.registerUsageCount()
2022-11-27 08:58:19 +01:00
})
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
let commands = content.match(regExp);
if (game.system.cruciblerpg.commands.processChatCommand(commands, content, msg)) {
return false;
}
}
return true;
});