2022-01-09 09:33:47 +01:00
|
|
|
/**
|
|
|
|
* YggDrasill system
|
|
|
|
* Author: Uberwald
|
|
|
|
* Software License: Prop
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Import Modules
|
|
|
|
import { YggdrasillActor } from "./yggdrasill-actor.js";
|
|
|
|
import { YggdrasillItemSheet } from "./yggdrasill-item-sheet.js";
|
|
|
|
import { YggdrasillActorSheet } from "./yggdrasill-actor-sheet.js";
|
|
|
|
import { YggdrasillFigurantSheet } from "./yggdrasill-figurant-sheet.js";
|
|
|
|
import { YggdrasillUtility } from "./yggdrasill-utility.js";
|
|
|
|
import { YggdrasillCombat } from "./yggdrasill-combat.js";
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|
|
|
|
/************************************************************************************/
|
|
|
|
Hooks.once("init", async function () {
|
|
|
|
console.log(`Initializing Yggdrasill`);
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// preload handlebars templates
|
|
|
|
YggdrasillUtility.preloadHandlebarsTemplates();
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
|
|
|
formula: "1d20",
|
|
|
|
decimals: 0
|
|
|
|
};
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.socket.on("system.fvtt-yggdrasill", data => {
|
|
|
|
YggdrasillUtility.onSocketMesssage(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
|
|
|
CONFIG.Actor.documentClass = YggdrasillActor;
|
|
|
|
CONFIG.Combat.documentClass = YggdrasillCombat;
|
|
|
|
CONFIG.Yggdrasill = {
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
|
|
|
Actors.unregisterSheet("core", ActorSheet);
|
|
|
|
Actors.registerSheet("fvtt-yggdrasill", YggdrasillActorSheet, { types: ["personnage"], makeDefault: true });
|
|
|
|
Actors.registerSheet("fvtt-yggdrasill", YggdrasillFigurantSheet, { types: ["figurant"], makeDefault: false });
|
|
|
|
Items.unregisterSheet("core", ItemSheet);
|
|
|
|
Items.registerSheet("fvtt-yggdrasill", YggdrasillItemSheet, { makeDefault: true });
|
|
|
|
|
|
|
|
// Init/registers
|
|
|
|
Hooks.on('renderChatLog', (log, html, data) => {
|
|
|
|
//YggdrasillUtility.registerChatCallbacks(html);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
function welcomeMessage() {
|
|
|
|
//ChatUtility.removeMyChatMessageContaining('<div id="welcome-message-sos">');
|
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user.id,
|
|
|
|
whisper: [game.user.id],
|
2022-01-30 21:01:10 +01:00
|
|
|
content: `<div id="welcome-message-yggdrasill"><span class="rdd-roll-part"><strong>Bienvenue à Yggdrasill !</strong>
|
|
|
|
<p>Yggdrasill est un Jeu de Rôle publié par 7ième Cercle : https://www.7emecercle.com/7C_site/jeux-de-roles/yggdrasill/</p>
|
|
|
|
<br>Yggdrasill est une propriété de 7ième Cercle.
|
|
|
|
</div>
|
2022-01-09 09:33:47 +01:00
|
|
|
` });
|
|
|
|
}
|
|
|
|
|
2022-01-30 21:01:10 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
// 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,
|
2022-09-21 11:42:09 +02:00
|
|
|
default: "",
|
2022-01-30 21:01:10 +01:00
|
|
|
type: String
|
|
|
|
});
|
|
|
|
|
|
|
|
let worldKey = game.settings.get(registerKey, "world-key")
|
|
|
|
if ( worldKey == undefined || worldKey == "" ) {
|
|
|
|
worldKey = randomID(32)
|
|
|
|
game.settings.set(registerKey, "world-key", worldKey )
|
|
|
|
}
|
2022-09-21 11:42:09 +02:00
|
|
|
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}"`
|
2022-02-19 09:30:57 +01:00
|
|
|
$.ajax(regURL)
|
2022-01-30 21:01:10 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-09 09:33:47 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.once("ready", function () {
|
|
|
|
|
|
|
|
// User warning
|
|
|
|
if (!game.user.isGM && game.user.character == undefined) {
|
|
|
|
ui.notifications.info("Attention ! Vous n'est connecté à aucun personnage");
|
|
|
|
ChatMessage.create({
|
|
|
|
content: "<b>WARNING</b> Le joueur " + game.user.name + " n'est pas connecté à un personnage !",
|
|
|
|
user: game.user._id
|
|
|
|
});
|
|
|
|
}
|
2022-01-30 21:01:10 +01:00
|
|
|
registerUsageCount("fvtt-yggdrasill")
|
|
|
|
welcomeMessage()
|
2022-01-09 09:33:47 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
Hooks.on("chatMessage", (html, content, msg) => {
|
|
|
|
if (content[0] == '/') {
|
|
|
|
let regExp = /(\S+)/g;
|
|
|
|
let commands = content.toLowerCase().match(regExp);
|
|
|
|
console.log(commands);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|