fvtt-pegasus-rpg/modules/pegasus-main.js

136 lines
4.9 KiB
JavaScript
Raw Normal View History

2021-12-02 07:38:59 +01:00
/**
* Pegasus system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { PegasusActor } from "./pegasus-actor.js";
import { PegasusItemSheet } from "./pegasus-item-sheet.js";
import { PegasusActorSheet } from "./pegasus-actor-sheet.js";
2022-09-05 08:57:02 +02:00
import { PegasusVehicleSheet } from "./pegasus-vehicle-sheet.js";
2021-12-02 07:38:59 +01:00
import { PegasusUtility } from "./pegasus-utility.js";
2023-09-13 17:37:30 +02:00
import { PegasusCombatTracker,PegasusCombat } from "./pegasus-combat.js";
2021-12-02 07:38:59 +01:00
import { PegasusItem } from "./pegasus-item.js";
2023-09-11 20:34:33 +02:00
import { PEGASUS_CONFIG } from "./pegasus-config.js"
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Pegasus RPG`);
/* -------------------------------------------- */
// preload handlebars templates
PegasusUtility.preloadHandlebarsTemplates();
2021-12-02 20:18:21 +01:00
/* -------------------------------------------- */
game.settings.register("fvtt-pegasus-rpg", "dice-max-level", {
name: "Maximum level value for dices lists",
2022-03-15 20:57:51 +01:00
hint: "Set the maximum level value for dices lists",
2021-12-02 20:18:21 +01:00
scope: "world",
config: true,
default: 20,
type: Number
2022-03-15 20:57:51 +01:00
})
2021-12-02 20:18:21 +01:00
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
game.socket.on("system.fvtt-pegasus-rpg", data => {
2022-03-06 20:07:41 +01:00
PegasusUtility.onSocketMesssage(data)
2021-12-02 07:38:59 +01:00
});
/* -------------------------------------------- */
// Define custom Entity classes
2022-01-30 09:44:37 +01:00
CONFIG.Combat.documentClass = PegasusCombat
CONFIG.Actor.documentClass = PegasusActor
CONFIG.Item.documentClass = PegasusItem
2023-09-13 17:37:30 +02:00
CONFIG.ui.combat = PegasusCombatTracker
2022-10-03 10:01:41 +02:00
game.system.pegasus = {
2023-09-11 20:34:33 +02:00
utility: PegasusUtility,
config: PEGASUS_CONFIG
2022-10-03 10:01:41 +02:00
}
2021-12-02 07:38:59 +01:00
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
2022-09-05 08:57:02 +02:00
Actors.registerSheet("fvtt-pegasus", PegasusActorSheet, { types: ["character"], makeDefault: true })
2023-09-13 17:37:30 +02:00
Actors.registerSheet("fvtt-pegasus", PegasusActorSheet, { types: ["npc"], makeDefault: true })
2022-09-05 08:57:02 +02:00
Actors.registerSheet("fvtt-pegasus", PegasusVehicleSheet, { types: ["vehicle"], makeDefault: false })
2021-12-02 07:38:59 +01:00
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-pegasus", PegasusItemSheet, { makeDefault: true });
2022-10-03 10:01:41 +02:00
PegasusUtility.init()
2021-12-02 07:38:59 +01:00
});
/* -------------------------------------------- */
function welcomeMessage() {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
2022-01-28 10:05:54 +01:00
content: `<div id="welcome-message-pegasus"><span class="rdd-roll-part">
<strong>Welcome to the Pegasus Engine CORE RPG.</strong>
<br>Created by GMD Online
2022-01-28 11:41:19 +01:00
<p>The Pegasus Engine is a available for free on our website. It is also available as a PDF and in Print format at an affordable price.</p>
<p>This project has been made possible thanks to all the Official GMD Members and Patreon Members that have supported me and as a result made it possible to supply this interface for free.</p>
2022-01-28 10:05:54 +01:00
<p>In return I have made available a fully detailed Compendium for FREE for all members, which can be obtained from the Members page on my website.</p>
2022-01-28 17:27:01 +01:00
<P>You too can become a supporter for future projects and enjoy amazing rewards.
<BR>Sign up Here : https://www.gmdonline.co.uk/gmdmemberspage/</p>
2022-01-28 11:41:19 +01:00
<p>GMD Online, GMD CORE RPG logo are © 2018 CORE Worlds and Game Rules © 2001. Interface © 2021 All rights reserved.</p>
<p>Enjoy and become the hero you were born to be!</p>
2021-12-02 07:38:59 +01:00
` });
}
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
PegasusUtility.ready();
// 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
});
}
2021-12-20 11:54:19 +01:00
// CSS patch for v9
if (game.version) {
let sidebar = document.getElementById("sidebar");
sidebar.style.width = "min-content";
}
2021-12-02 07:38:59 +01:00
welcomeMessage();
});
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
2022-01-06 18:22:05 +01:00
let commands = content.match(regExp);
if (game.system.pegasus.commands.processChatCommand(commands, content, msg)) {
return false;
}
2021-12-02 07:38:59 +01:00
}
return true;
});
2022-01-06 18:22:05 +01:00