fvtt-wasteland/modules/wasteland-main.js

136 lines
4.8 KiB
JavaScript
Raw Normal View History

2023-11-26 16:18:04 +01:00
/**
* Wasteland system
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
import { WastelandActor } from "./wasteland-actor.js";
import { WastelandItemSheet } from "./wasteland-item-sheet.js";
import { WastelandActorSheet } from "./wasteland-actor-sheet.js";
2023-12-02 09:03:58 +01:00
import { WastelandCreatureSheet } from "./wasteland-creature-sheet.js";
2023-11-26 16:18:04 +01:00
import { WastelandUtility } from "./wasteland-utility.js";
import { WastelandCombat } from "./wasteland-combat.js";
import { WastelandItem } from "./wasteland-item.js";
2023-11-28 21:42:31 +01:00
import { WASTELAND_CONFIG } from "./wasteland-config.js";
2024-02-08 12:57:36 +01:00
import { ClassCounter} from "https://www.uberwald.me/fvtt_appcount/count-class-ready.js"
2023-11-26 16:18:04 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
console.log(`Initializing Wasteland RPG`);
/* -------------------------------------------- */
// preload handlebars templates
WastelandUtility.preloadHandlebarsTemplates();
2024-01-08 07:56:51 +01:00
2023-11-26 16:18:04 +01:00
/* -------------------------------------------- */
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
/* -------------------------------------------- */
2023-11-26 17:00:12 +01:00
game.socket.on("system.fvtt-wasteland", data => {
2023-11-26 16:18:04 +01:00
WastelandUtility.onSocketMesssage(data);
});
/* -------------------------------------------- */
// Define custom Entity classes
CONFIG.Combat.documentClass = WastelandCombat
CONFIG.Actor.documentClass = WastelandActor
CONFIG.Item.documentClass = WastelandItem
2023-11-28 21:42:31 +01:00
game.system.wasteland = {
config: WASTELAND_CONFIG
}
2023-11-26 16:18:04 +01:00
/* -------------------------------------------- */
// Register sheet application classes
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("fvtt-wasteland", WastelandActorSheet, { types: ["personnage"], makeDefault: true })
2023-12-02 09:03:58 +01:00
Actors.registerSheet("fvtt-wasteland", WastelandCreatureSheet, { types: ["creature"], makeDefault: false });
2023-11-26 16:18:04 +01:00
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("fvtt-wasteland", WastelandItemSheet, { makeDefault: true })
WastelandUtility.init();
2024-01-08 07:56:51 +01:00
2023-11-26 16:18:04 +01:00
});
/* -------------------------------------------- */
function welcomeMessage() {
ChatMessage.create({
user: game.user.id,
whisper: [game.user.id],
content: `<div id="welcome-message-Wasteland"><span class="rdd-roll-part">
2023-11-30 18:50:32 +01:00
<strong>Bienvenue dans les Wasteland !</strong>
2023-11-26 16:18:04 +01:00
<p>Les livres de Wasteland sont nécessaires pour jouer : https://www.titam-france.fr</p>
<p>Wasteland est jeu de rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.</p>
2023-12-06 10:14:26 +01:00
<p>Système développé par LeRatierBretonnien, avec le support de Prêtre. Plus d'infos et aides sur le <a href="https://discord.gg/pPSDNJk">Discord FR de Foundry</a>.</p>
2023-11-26 16:18:04 +01:00
` });
}
2023-12-04 18:32:55 +01:00
/* -------------------------------------------- */
async function importDefaultScene() {
let exists = game.scenes.find(j => j.name == "Accueil");
if (!exists) {
const scenes = await WastelandUtility.loadCompendium("fvtt-wasteland.scenes")
let newDocuments = scenes.filter(i => i.name == "Accueil");
await game.scenes.documentClass.create(newDocuments);
game.scenes.find(i => i.name == "Accueil").activate();
}
}
2023-11-26 16:18:04 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.once("ready", function () {
WastelandUtility.ready();
2024-01-08 07:56:51 +01:00
2024-02-08 12:57:36 +01:00
ClassCounter.registerUsageCount()
2024-01-08 07:56:51 +01:00
welcomeMessage();
2023-11-26 16:18:04 +01: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
});
}
2024-01-08 07:56:51 +01:00
if (!game.user.isGM && game.user.character && !game.user.character.prototypeToken.actorLink) {
ui.notifications.info("Le token de du joueur n'est pas connecté à l'acteur !");
ChatMessage.create({
content: "<b>ATTENTION</b> Le token du joueur " + game.user.name + " n'est pas connecté à l'acteur !",
user: game.user._id
});
}
2023-12-04 18:32:55 +01:00
importDefaultScene();
2023-11-26 16:18:04 +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.wasteland.commands.processChatCommand(commands, content, msg)) {
return false;
}
}
return true;
});