2023-02-01 14:28:08 +01:00
|
|
|
/**
|
|
|
|
* Malefices system
|
|
|
|
* Author: Uberwald
|
|
|
|
* Software License: Prop
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Import Modules
|
|
|
|
import { MaleficesActor } from "./malefices-actor.js";
|
|
|
|
import { MaleficesItemSheet } from "./malefices-item-sheet.js";
|
|
|
|
import { MaleficesActorSheet } from "./malefices-actor-sheet.js";
|
|
|
|
import { MaleficesNPCSheet } from "./malefices-npc-sheet.js";
|
|
|
|
import { MaleficesUtility } from "./malefices-utility.js";
|
|
|
|
import { MaleficesCombat } from "./malefices-combat.js";
|
|
|
|
import { MaleficesItem } from "./malefices-item.js";
|
|
|
|
import { MaleficesHotbar } from "./malefices-hotbar.js"
|
2023-02-08 17:51:16 +01:00
|
|
|
import { MaleficesCharacterSummary } from "./malefices-summary-app.js"
|
2023-02-01 14:28:08 +01:00
|
|
|
import { MALEFICES_CONFIG } from "./malefices-config.js"
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
Hooks.once("init", async function () {
|
|
|
|
|
|
|
|
console.log(`Initializing Malefices RPG`);
|
2023-02-25 09:38:35 +01:00
|
|
|
|
2023-02-01 14:28:08 +01:00
|
|
|
game.system.malefices = {
|
|
|
|
config: MALEFICES_CONFIG,
|
|
|
|
MaleficesHotbar
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// preload handlebars templates
|
|
|
|
MaleficesUtility.preloadHandlebarsTemplates();
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
|
|
|
formula: "1d6",
|
|
|
|
decimals: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.socket.on("system.fvtt-malefices", data => {
|
|
|
|
MaleficesUtility.onSocketMesssage(data)
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Combat.documentClass = MaleficesCombat
|
|
|
|
CONFIG.Actor.documentClass = MaleficesActor
|
|
|
|
CONFIG.Item.documentClass = MaleficesItem
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("fvtt-malefices", MaleficesActorSheet, { types: ["personnage"], makeDefault: true });
|
|
|
|
Actors.registerSheet("fvtt-malefices", MaleficesNPCSheet, { types: ["pnj"], makeDefault: false });
|
|
|
|
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("fvtt-malefices", MaleficesItemSheet, { makeDefault: true });
|
|
|
|
|
2023-03-08 20:24:19 +01:00
|
|
|
MaleficesUtility.init()
|
|
|
|
|
2023-02-01 14:28:08 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
function welcomeMessage() {
|
2023-02-25 09:38:35 +01:00
|
|
|
if (game.user.isGM) {
|
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user.id,
|
|
|
|
whisper: [game.user.id],
|
|
|
|
content: `<div id="welcome-message-malefices"><span class="rdd-roll-part">
|
|
|
|
<strong>Bienvenu dans Malefices, le JDR qui sent le souffre !</strong>
|
|
|
|
<p>Le Livre de Base de Maléfices v4 est nécessaire pour jouer : https://arkhane-asylum.fr/en/malefices/</p>
|
|
|
|
<p>Maléfices et un jeu de rôle publié par Arkhane Asylum Publishing, tout les droits leur appartiennent.</p>
|
|
|
|
<p>Système développé par LeRatierBretonnien avec l'aide de la Dame du Lac et Malik, support sur le <a href="https://discord.gg/pPSDNJk">Discord FR de Foundry</a>.</p>
|
2023-02-28 13:06:46 +01:00
|
|
|
<p>Commandes : /tirage pour le tirage des tarots, /carte pour tirer une simple carte et /resume pour le résumé des PJs (MJ seulement)` });
|
2023-02-25 09:38:35 +01:00
|
|
|
}
|
2023-02-01 14:28:08 +01:00
|
|
|
}
|
2023-02-08 17:51:16 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register world usage statistics
|
2023-02-25 09:38:35 +01:00
|
|
|
function registerUsageCount(registerKey) {
|
|
|
|
if (game.user.isGM) {
|
2023-02-08 17:51:16 +01:00
|
|
|
game.settings.register(registerKey, "world-key", {
|
|
|
|
name: "Unique world key",
|
|
|
|
scope: "world",
|
|
|
|
config: false,
|
|
|
|
default: "",
|
|
|
|
type: String
|
|
|
|
});
|
|
|
|
|
|
|
|
let worldKey = game.settings.get(registerKey, "world-key")
|
2023-02-25 09:38:35 +01:00
|
|
|
if (worldKey == undefined || worldKey == "") {
|
2023-02-08 17:51:16 +01:00
|
|
|
worldKey = randomID(32)
|
2023-02-25 09:38:35 +01:00
|
|
|
game.settings.set(registerKey, "world-key", worldKey)
|
2023-02-08 17:51:16 +01:00
|
|
|
}
|
|
|
|
// Simple API counter
|
|
|
|
let regURL = `https://www.uberwald.me/fvtt_appcount/count.php?name="${registerKey}"&worldKey="${worldKey}"&version="${game.release.generation}.${game.release.build}"&system="${game.system.id}"&systemversion="${game.system.version}"`
|
|
|
|
//$.ajaxSetup({
|
2023-02-25 09:38:35 +01:00
|
|
|
//headers: { 'Access-Control-Allow-Origin': '*' }
|
2023-02-08 17:51:16 +01:00
|
|
|
//})
|
|
|
|
$.ajax(regURL)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-01 14:28:08 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.once("ready", function () {
|
|
|
|
|
|
|
|
// User warning
|
|
|
|
if (!game.user.isGM && game.user.character == undefined) {
|
|
|
|
ui.notifications.info("Attention ! Aucun personnage relié au joueur !");
|
|
|
|
ChatMessage.create({
|
|
|
|
content: "<b>WARNING</b> Le joueur " + game.user.name + " n'est pas relié à un personnage !",
|
|
|
|
user: game.user._id
|
|
|
|
});
|
|
|
|
}
|
2023-02-25 09:38:35 +01:00
|
|
|
|
2023-02-08 17:51:16 +01:00
|
|
|
registerUsageCount('fvtt-malefices')
|
2023-02-01 14:28:08 +01:00
|
|
|
welcomeMessage();
|
|
|
|
MaleficesUtility.ready()
|
2023-02-25 09:38:35 +01:00
|
|
|
MaleficesCharacterSummary.ready()
|
2023-02-08 17:51:16 +01:00
|
|
|
|
2023-02-01 14:28:08 +01:00
|
|
|
})
|
|
|
|
|
2023-02-08 17:51:16 +01:00
|
|
|
|
2023-02-01 14:28:08 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
|
|
if (content[0] == '/') {
|
|
|
|
let regExp = /(\S+)/g;
|
|
|
|
let commands = content.match(regExp);
|
2023-02-07 19:55:33 +01:00
|
|
|
if (game.system.malefices.commands.processChatCommand(commands, content, msg)) {
|
2023-02-01 14:28:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|