fvtt-hawkmoon-cyd/modules/hawkmoon-main.js

142 lines
5.0 KiB
JavaScript
Raw Permalink Normal View History

2022-10-22 11:09:48 +02:00
/**
* Hawkmoon system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { HawkmoonActor } from "./hawkmoon-actor.js";
import { HawkmoonItemSheet } from "./hawkmoon-item-sheet.js";
import { HawkmoonActorSheet } from "./hawkmoon-actor-sheet.js";
2022-11-13 23:01:41 +01:00
import { HawkmoonCreatureSheet } from "./hawkmoon-creature-sheet.js";
2022-11-10 23:43:51 +01:00
import { HawkmoonCelluleSheet } from "./hawkmoon-cellule-sheet.js";
2022-10-22 11:09:48 +02:00
import { HawkmoonUtility } from "./hawkmoon-utility.js";
import { HawkmoonCombat } from "./hawkmoon-combat.js";
import { HawkmoonItem } from "./hawkmoon-item.js";
2022-10-28 21:44:49 +02:00
import { HawkmoonAutomation } from "./hawkmoon-automation.js";
2022-12-03 23:13:08 +01:00
import { HawkmoonTokenHud } from "./hawkmoon-hud.js";
2024-05-02 09:27:16 +02:00
import { HAWKMOON_CONFIG } from "./hawkmoon-config.js";
2022-10-22 11:09:48 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Hawkmoon RPG`);
/* -------------------------------------------- */
// preload handlebars templates
2022-10-24 18:36:18 +02:00
HawkmoonUtility.preloadHandlebarsTemplates()
2022-10-22 11:09:48 +02:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
2022-11-10 23:43:51 +01:00
formula: "1d10",
2022-10-22 11:09:48 +02:00
decimals: 1
};
/* -------------------------------------------- */
game.socket.on("system.fvtt-hawkmoon-cyd", data => {
2022-10-24 18:36:18 +02:00
HawkmoonUtility.onSocketMesssage(data)
2022-10-22 11:09:48 +02:00
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = HawkmoonCombat
CONFIG.Actor.documentClass = HawkmoonActor
CONFIG.Item.documentClass = HawkmoonItem
2022-10-23 21:26:18 +02:00
game.system.hawkmoon = {
2022-10-24 18:36:18 +02:00
HawkmoonUtility,
2024-05-02 09:27:16 +02:00
HawkmoonAutomation,
config : HAWKMOON_CONFIG
2022-10-22 11:09:48 +02:00
}
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonActorSheet, { types: ["personnage"], makeDefault: true })
2022-11-13 23:01:41 +01:00
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonCreatureSheet, { types: ["creature"], makeDefault: true })
Actors.registerSheet("fvtt-hawkmoon-cyd", HawkmoonCelluleSheet, { types: ["cellule"], makeDefault: true });
2022-10-22 11:09:48 +02:00
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-hawkmoon-cyd", HawkmoonItemSheet, { makeDefault: true })
2022-10-24 18:36:18 +02:00
HawkmoonUtility.init()
2022-10-28 21:44:49 +02:00
HawkmoonAutomation.init()
2022-12-03 23:13:08 +01:00
HawkmoonTokenHud.init()
2022-10-23 09:55:02 +02:00
2022-10-22 11:09:48 +02:00
});
/* -------------------------------------------- */
function welcomeMessage() {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-Hawkmoon"><span class="rdd-roll-part">
2022-10-23 09:55:02 +02:00
<strong>Bienvenue dans Hawkmoon et le troisième Millénaire !</strong>
2022-10-22 11:09:48 +02:00
<p>Les livres de Hawkmoon sont nécessaires pour jouer : https://www.titam-france.fr</p>
2022-12-11 18:42:16 +01:00
<p>Hawkmoon est jeu de rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.</p>
<p>Système développé par LeRatierBretonnien, support sur le <a href="https://discord.gg/pPSDNJk">Discord FR de Foundry</a>.</p>
2022-10-22 11:09:48 +02:00
` });
}
2024-05-05 18:06:29 +02:00
/* -------------------------------------------- */
async function importDefaultScene() {
let exists = game.scenes.find(j => j.name == "Accueil");
if (!exists) {
2024-05-23 11:33:02 +02:00
const scenes = await HawkmoonUtility.loadCompendium("fvtt-hawkmoon-cyd.scenes")
2024-05-05 18:06:29 +02:00
let newDocuments = scenes.filter(i => i.name == "Accueil");
if (newDocuments) {
await game.scenes.documentClass.create(newDocuments);
game.scenes.find(i => i.name == "Accueil").activate();
}
}
}
2022-10-22 11:09:48 +02:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
2022-12-03 23:13:08 +01:00
HawkmoonUtility.ready()
2022-10-22 11:09:48 +02:00
// User warning
if (!game.user.isGM && game.user.character == undefined) {
ui.notifications.info("Attention ! Aucun personnage n'est relié au joueur !");
ChatMessage.create({
content: "<b>ATTENTION</b> Le joueur " + game.user.name + " n'est relié à aucun personnage !",
user: game.user._id
});
}
2022-10-23 09:55:02 +02:00
2024-02-24 15:54:47 +01:00
import("https://www.uberwald.me/fvtt_appcount/count-class-ready.js").then(moduleCounter=>{
console.log("ClassCounter loaded", moduleCounter)
moduleCounter.ClassCounter.registerUsageCount()
}).catch(err=>
console.log("No stats available, giving up.")
)
2024-05-05 18:06:29 +02:00
importDefaultScene()
2022-10-22 11:09:48 +02:00
welcomeMessage()
2022-10-23 09:55:02 +02:00
2022-10-22 11:09:48 +02: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.mournblade.commands.processChatCommand(commands, content, msg)) {
return false;
}
}
return true;
});