2022-12-26 00:33:13 +01:00
|
|
|
/**
|
|
|
|
* Heritiers system
|
|
|
|
* Author: Uberwald
|
|
|
|
* Software License: Prop
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Import Modules
|
2022-12-26 10:13:05 +01:00
|
|
|
import { HeritiersActor } from "./heritiers-actor.js";
|
|
|
|
import { HeritiersItemSheet } from "./heritiers-item-sheet.js";
|
|
|
|
import { HeritiersActorSheet } from "./heritiers-actor-sheet.js";
|
2023-03-13 09:00:49 +01:00
|
|
|
import { HeritiersActorPNJSheet } from "./heritiers-actor-pnj-sheet.js";
|
2022-12-26 00:33:13 +01:00
|
|
|
import { HeritiersUtility } from "./heritiers-utility.js";
|
2022-12-26 10:13:05 +01:00
|
|
|
import { HeritiersCombat } from "./heritiers-combat.js";
|
|
|
|
import { HeritiersItem } from "./heritiers-item.js";
|
2022-12-26 20:46:03 +01:00
|
|
|
import { HERITIERS_CONFIG } from "./heritiers-config.js";
|
2022-12-26 00:33:13 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
Hooks.once("init", async function () {
|
|
|
|
console.log(`Initializing Heritiers RPG`);
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// preload handlebars templates
|
|
|
|
HeritiersUtility.preloadHandlebarsTemplates()
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
|
|
|
formula: "1d10",
|
|
|
|
decimals: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.socket.on("system.fvtt-les-heritiers", data => {
|
|
|
|
HeritiersUtility.onSocketMesssage(data)
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Combat.documentClass = HeritiersCombat
|
|
|
|
CONFIG.Actor.documentClass = HeritiersActor
|
|
|
|
CONFIG.Item.documentClass = HeritiersItem
|
2024-05-23 11:25:51 +02:00
|
|
|
// Create an array of values from 0 to 10
|
|
|
|
HERITIERS_CONFIG.listNiveau = Array.from({ length: 11 }, (v, k) => k)
|
|
|
|
// Create an object of bonus/malus from -6 to +6 signed
|
|
|
|
HERITIERS_CONFIG.bonusMalus = Array.from({ length: 7 }, (v, k) => k - 6)
|
2022-12-26 20:46:03 +01:00
|
|
|
game.system.lesheritiers = {
|
2022-12-26 00:33:13 +01:00
|
|
|
HeritiersUtility,
|
2022-12-26 20:46:03 +01:00
|
|
|
config: HERITIERS_CONFIG
|
2022-12-26 00:33:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("fvtt-les-heritiers", HeritiersActorSheet, { types: ["personnage"], makeDefault: true })
|
2023-03-13 09:00:49 +01:00
|
|
|
Actors.registerSheet("fvtt-les-heritiers", HeritiersActorPNJSheet, { types: ["pnj"], makeDefault: true })
|
2022-12-26 00:33:13 +01:00
|
|
|
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("fvtt-les-heritiers", HeritiersItemSheet, { makeDefault: true })
|
|
|
|
|
|
|
|
HeritiersUtility.init()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
function welcomeMessage() {
|
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user.id,
|
|
|
|
whisper: [game.user.id],
|
2022-12-26 10:13:05 +01:00
|
|
|
content: `<div id="welcome-message-heritiers"><span class="rdd-roll-part">
|
|
|
|
<strong>Bienvenue dans Les Heritiers et la Belle Epoque !</strong>
|
|
|
|
<p>Les livres du JDR Les Heritiers sont nécessaires pour jouer : https://www.titam-france.fr</p>
|
|
|
|
<p>Les Heritiers est jeu de rôle publié par Titam France/Sombres projets, tout les droits leur appartiennent.</p>
|
2022-12-26 00:33:13 +01:00
|
|
|
<p>Système développé par LeRatierBretonnien, support sur le <a href="https://discord.gg/pPSDNJk">Discord FR de Foundry</a>.</p>
|
|
|
|
` });
|
|
|
|
}
|
|
|
|
|
2024-03-06 18:46:53 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
async function importDefaultScene() {
|
|
|
|
let exists = game.scenes.find(j => j.name == "Accueil");
|
|
|
|
if (!exists) {
|
|
|
|
const scenes = await HeritiersUtility.loadCompendium("fvtt-les-heritiers.scenes")
|
|
|
|
let newDocuments = scenes.filter(i => i.name == "Accueil");
|
|
|
|
await game.scenes.documentClass.create(newDocuments);
|
|
|
|
game.scenes.find(i => i.name == "Accueil").activate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-26 00:33:13 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.once("ready", function () {
|
|
|
|
|
|
|
|
HeritiersUtility.ready()
|
|
|
|
|
|
|
|
// 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-02-08 12:56:25 +01:00
|
|
|
|
2024-03-01 13:39:32 +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-03-06 18:46:53 +01:00
|
|
|
welcomeMessage();
|
|
|
|
importDefaultScene();
|
2022-12-26 00:33:13 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
|
|
if (content[0] == '/') {
|
|
|
|
let regExp = /(\S+)/g;
|
|
|
|
let commands = content.match(regExp);
|
2024-03-06 18:46:53 +01:00
|
|
|
if (game.system.lesheritiers.commands.processChatCommand(commands, content, msg)) {
|
2022-12-26 00:33:13 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|