This repository has been archived on 2024-05-29. You can view files and clone it, but cannot push or open issues or pull requests.
fvtt-warhero/modules/warhero-main.js

114 lines
3.7 KiB
JavaScript
Raw Normal View History

2023-01-04 21:24:56 +01:00
/**
2023-01-04 22:09:09 +01:00
* Warhero system
2023-01-04 21:24:56 +01:00
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
2023-01-04 22:09:09 +01:00
import { WarheroActor } from "./warhero-actor.js";
import { WarheroItemSheet } from "./warhero-item-sheet.js";
import { WarheroActorSheet } from "./warhero-actor-sheet.js";
import { WarheroNPCSheet } from "./warhero-npc-sheet.js";
2023-02-08 21:19:53 +01:00
import { WarheroMonsterSheet } from "./warhero-monster-sheet.js";
2023-01-04 22:09:09 +01:00
import { WarheroUtility } from "./warhero-utility.js";
import { WarheroCombat } from "./warhero-combat.js";
import { WarheroItem } from "./warhero-item.js";
import { WarheroHotbar } from "./warhero-hotbar.js"
import { WarheroCommands } from "./warhero-commands.js"
2023-01-04 22:21:49 +01:00
import { WARHERO_CONFIG } from "./warhero-config.js"
2023-01-04 21:24:56 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
2023-01-04 22:09:09 +01:00
console.log(`Initializing Warhero RPG`);
2023-01-04 21:24:56 +01:00
2023-01-04 22:21:49 +01:00
game.system.warhero = {
2023-01-04 22:09:09 +01:00
WarheroHotbar,
2023-01-04 22:21:49 +01:00
WarheroCommands,
config: WARHERO_CONFIG
2023-01-04 21:24:56 +01:00
}
/* -------------------------------------------- */
// preload handlebars templates
2023-01-04 22:09:09 +01:00
WarheroUtility.preloadHandlebarsTemplates();
2023-01-04 21:24:56 +01:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
2023-01-04 22:09:09 +01:00
game.socket.on("system.fvtt-warhero", data => {
WarheroUtility.onSocketMesssage(data)
2023-01-04 21:24:56 +01:00
});
/* -------------------------------------------- */
// Define custom Entity classes
2023-01-04 22:09:09 +01:00
CONFIG.Combat.documentClass = WarheroCombat
CONFIG.Actor.documentClass = WarheroActor
CONFIG.Item.documentClass = WarheroItem
//CONFIG.Token.objectClass = WarheroToken
2023-01-04 21:24:56 +01:00
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
2023-02-08 21:19:53 +01:00
Actors.registerSheet("fvtt-warhero", WarheroActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("fvtt-warhero", WarheroNPCSheet, { types: ["npc"], makeDefault: false });
Actors.registerSheet("fvtt-warhero", WarheroMonsterSheet, { types: ["monster"], makeDefault: false });
2023-01-04 21:24:56 +01:00
Items.unregisterSheet("core", ItemSheet);
2023-02-08 21:19:53 +01:00
Items.registerSheet("fvtt-warhero", WarheroItemSheet, { makeDefault: true });
2023-01-04 21:24:56 +01:00
2023-01-04 22:09:09 +01:00
WarheroUtility.init()
2023-01-04 21:24:56 +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 !");
2023-01-21 17:56:14 +01:00
/*ChatMessage.create({
2023-01-04 21:24:56 +01:00
content: "<b>WARNING</b> The player " + game.user.name + " is not linked to a character !",
user: game.user._id
2023-01-21 17:56:14 +01:00
});*/
2023-01-04 21:24:56 +01:00
}
// CSS patch for v9
2023-02-20 10:16:17 +01:00
/*if (game.version) {
2023-01-04 21:24:56 +01:00
let sidebar = document.getElementById("sidebar");
sidebar.style.width = "min-content";
2023-02-20 10:16:17 +01:00
}*/
2023-01-04 21:24:56 +01:00
2023-02-20 10:16:17 +01:00
//welcomeMessage();
2023-01-04 22:09:09 +01:00
WarheroUtility.ready()
2023-02-20 10:16:17 +01:00
//WarheroHotbar.initDropbar()
2023-01-04 21:24:56 +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;
});