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";
|
|
|
|
import { PegasusNPCSheet } from "./pegasus-npc-sheet.js";
|
|
|
|
import { PegasusUtility } from "./pegasus-utility.js";
|
|
|
|
import { PegasusCombat } from "./pegasus-combat.js";
|
|
|
|
import { PegasusItem } from "./pegasus-item.js";
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* 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",
|
|
|
|
hint: "Se the maximum level value for dices lists",
|
|
|
|
scope: "world",
|
|
|
|
config: true,
|
|
|
|
default: 20,
|
|
|
|
type: Number
|
|
|
|
});
|
|
|
|
|
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 => {
|
|
|
|
PegasusUtility.onSocketMesssage(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Combat.documentClass = PegasusCombat;
|
|
|
|
CONFIG.Actor.documentClass = PegasusActor;
|
|
|
|
CONFIG.Item.documentClass = PegasusItem;
|
2022-01-06 18:22:05 +01:00
|
|
|
game.system.pegasus = { };
|
2021-12-02 07:38:59 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("fvtt-pegasus", PegasusActorSheet, { types: ["character"], makeDefault: true });
|
|
|
|
Actors.registerSheet("fvtt-pegasus", PegasusNPCSheet, { types: ["npc"], makeDefault: false });
|
|
|
|
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("fvtt-pegasus", PegasusItemSheet, { makeDefault: true });
|
|
|
|
|
|
|
|
PegasusUtility.init();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
function welcomeMessage() {
|
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user.id,
|
|
|
|
whisper: [game.user.id],
|
|
|
|
content: `<div id="welcome-message-pegasus"><span class="rdd-roll-part">Welcome !</div>
|
|
|
|
` });
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* 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
|
|
|
|