145 lines
4.5 KiB
JavaScript
145 lines
4.5 KiB
JavaScript
/**
|
|
* Te Deum system
|
|
* Author: Uberwald
|
|
* Software License: Prop
|
|
*/
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* -------------------------------------------- */
|
|
// Import Modules
|
|
import { TeDeumActor } from "./actors/tedeum-actor.js";
|
|
import { TeDeumItemSheet } from "./items/tedeum-item-sheet.js";
|
|
import { TeDeumActorSheet } from "./actors/tedeum-actor-sheet.js";
|
|
import { TeDeumPJSchema } from "./common/tedeum-schema-pj.js";
|
|
import { TeDeumUtility } from "./common/tedeum-utility.js";
|
|
import { TeDeumCombat } from "./app/tedeum-combat.js";
|
|
import { TeDeumItem } from "./items/tedeum-item.js";
|
|
import { TeDeumHotbar } from "./app/tedeum-hotbar.js"
|
|
import { TEDEUM_CONFIG } from "./common/tedeum-config.js"
|
|
|
|
/* -------------------------------------------- */
|
|
/* Foundry VTT Initialization */
|
|
/* -------------------------------------------- */
|
|
|
|
/************************************************************************************/
|
|
Hooks.once("init", async function () {
|
|
|
|
console.log(`Initializing TeDeum RPG`);
|
|
|
|
game.system.tedeum = {
|
|
config: TEDEUM_CONFIG,
|
|
TeDeumHotbar
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
// preload handlebars templates
|
|
TeDeumUtility.preloadHandlebarsTemplates();
|
|
|
|
/* -------------------------------------------- */
|
|
// Set an initiative formula for the system
|
|
CONFIG.Combat.initiative = {
|
|
formula: "1d6",
|
|
decimals: 1
|
|
};
|
|
|
|
/* -------------------------------------------- */
|
|
game.socket.on("system.fvtt-tedeum", data => {
|
|
TeDeumUtility.onSocketMesssage(data)
|
|
});
|
|
|
|
CONFIG.Combat.documentClass = TeDeumCombat
|
|
CONFIG.Actor.documentClass = TeDeumActor;
|
|
CONFIG.Item.documentClass = TeDeumItem
|
|
CONFIG.Actor.dataModels = {
|
|
pj: TeDeumPJSchema,
|
|
pnj: TeDeumPJSchema,
|
|
};
|
|
CONFIG.Item.dataModels = {
|
|
arme: models.TeDeumArmeSchema,
|
|
competence: models.TeDeumCompetenceSchema,
|
|
};
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
Actors.registerSheet(SYSTEM_ID, TeDeumActorPJSheet, { types: ["pj"], makeDefault: true });
|
|
Actors.registerSheet(SYSTEM_ID, TeDeumActorPJSheet, { types: ["pnj"], makeDefault: true });
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
Items.registerSheet(SYSTEM_ID, TeDeumItemSheet, { makeDefault: true });
|
|
|
|
TeDeumUtility.init()
|
|
});
|
|
|
|
/* -------------------------------------------- */
|
|
function welcomeMessage() {
|
|
if (game.user.isGM) {
|
|
ChatMessage.create({
|
|
user: game.user.id,
|
|
whisper: [game.user.id],
|
|
content: `<div id="welcome-message-tedeum"><span class="rdd-roll-part">
|
|
<strong>Bienvenu dans TeDeum !</strong>` });
|
|
}
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
// Register world usage statistics
|
|
function registerUsageCount(registerKey) {
|
|
if (game.user.isGM) {
|
|
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")
|
|
if (worldKey == undefined || worldKey == "") {
|
|
worldKey = randomID(32)
|
|
game.settings.set(registerKey, "world-key", worldKey)
|
|
}
|
|
// 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({
|
|
//headers: { 'Access-Control-Allow-Origin': '*' }
|
|
//})
|
|
$.ajax(regURL)
|
|
}
|
|
}
|
|
|
|
/* -------------------------------------------- */
|
|
/* 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
|
|
});
|
|
}
|
|
|
|
registerUsageCount(game.system.id)
|
|
welcomeMessage();
|
|
TeDeumUtility.ready()
|
|
|
|
})
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
/* Foundry VTT Initialization */
|
|
/* -------------------------------------------- */
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
if (content[0] == '/') {
|
|
let regExp = /(\S+)/g;
|
|
let commands = content.match(regExp);
|
|
if (game.system.tedeum.commands.processChatCommand(commands, content, msg)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
});
|
|
|