fvtt-te-deum/modules/tedeum-main.js

138 lines
4.4 KiB
JavaScript
Raw Normal View History

2023-12-11 20:11:10 +01:00
/**
2023-12-11 21:41:51 +01:00
* Te Deum system
2023-12-11 20:11:10 +01:00
* Author: Uberwald
* Software License: Prop
*/
/* -------------------------------------------- */
/* -------------------------------------------- */
// Import Modules
2023-12-11 21:41:51 +01:00
import { TeDeumActor } from "./actors/tedeum-actor.js";
2023-12-11 22:44:06 +01:00
import { TeDeumActorPJSheet } from "./actors/tedeum-actor-sheet.js";
2024-02-19 22:02:44 +01:00
import { TeDeumPJSchema } from "./data/tedeum-schema-pj.js";
import { TeDeumArmeSchema } from "./data/tedeum-schema-arme.js";
import { TeDeumArmureSchema } from "./data/tedeum-schema-armure.js";
import { TeDeumCompetenceSchema } from "./data/tedeum-schema-competence.js";
import { TeDeumEquipementSchema } from "./data/tedeum-schema-equipement.js";
import { TeDeumOrigineSchema } from "./data/tedeum-schema-origine.js";
import { TeDeumEducationSchema } from "./data/tedeum-schema-education.js";
2024-06-04 21:05:54 +02:00
import { TeDeumGraceSchema } from "./data/tedeum-schema-grace.js";
import { TeDeumBlessureSchema } from "./data/tedeum-schema-blessure.js";
import { TeDeumMaladieSchema } from "./data/tedeum-schema-maladie.js";
2024-02-19 22:02:44 +01:00
2023-12-11 21:41:51 +01:00
import { TeDeumItem } from "./items/tedeum-item.js";
2024-02-19 22:02:44 +01:00
import { TeDeumItemSheet } from "./items/tedeum-item-sheet.js";
2023-12-11 21:41:51 +01:00
import { TeDeumHotbar } from "./app/tedeum-hotbar.js"
2024-02-19 22:02:44 +01:00
import { TeDeumCombat } from "./app/tedeum-combat.js";
2025-01-31 11:54:52 +01:00
import { TeDeumCharacterCreator } from "./app/tedeum-character-creator.js"
2023-12-11 20:11:10 +01:00
2024-02-19 22:02:44 +01:00
import { TeDeumUtility } from "./common/tedeum-utility.js";
2024-02-29 22:35:12 +01:00
import { TEDEUM_CONFIG } from "./common/tedeum-config.js";
2023-12-11 20:11:10 +01:00
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
/************************************************************************************/
Hooks.once("init", async function () {
2023-12-11 21:41:51 +01:00
console.log(`Initializing TeDeum RPG`);
2023-12-11 20:11:10 +01:00
2023-12-11 21:41:51 +01:00
game.system.tedeum = {
2023-12-11 22:24:19 +01:00
config: TEDEUM_CONFIG,
2025-01-31 11:54:52 +01:00
TeDeumCharacterCreator,
2023-12-11 21:41:51 +01:00
TeDeumHotbar
2023-12-11 20:11:10 +01:00
}
2024-02-19 22:02:44 +01:00
console.log(`Initializing TeDeum RPG 2`);
2023-12-11 20:11:10 +01:00
// preload handlebars templates
2023-12-11 21:41:51 +01:00
TeDeumUtility.preloadHandlebarsTemplates();
2023-12-11 20:11:10 +01:00
// Set an initiative formula for the system
CONFIG.Combat.initiative = {
formula: "1d6",
decimals: 1
};
2024-02-19 22:02:44 +01:00
game.socket.on("system.fvtt-te-deum", data => {
2023-12-11 21:41:51 +01:00
TeDeumUtility.onSocketMesssage(data)
2023-12-11 20:11:10 +01:00
});
2024-02-19 22:02:44 +01:00
//CONFIG.Combat.documentClass = TeDeumCombat
2023-12-11 22:24:19 +01:00
CONFIG.Actor.documentClass = TeDeumActor;
2023-12-11 21:41:51 +01:00
CONFIG.Item.documentClass = TeDeumItem
2023-12-11 22:24:19 +01:00
CONFIG.Actor.dataModels = {
pj: TeDeumPJSchema,
pnj: TeDeumPJSchema,
};
CONFIG.Item.dataModels = {
2023-12-11 22:44:06 +01:00
arme: TeDeumArmeSchema,
competence: TeDeumCompetenceSchema,
equipement: TeDeumEquipementSchema,
armure: TeDeumArmureSchema,
2024-02-19 22:02:44 +01:00
origine: TeDeumOrigineSchema,
2024-06-04 21:05:54 +02:00
education: TeDeumEducationSchema,
grace: TeDeumGraceSchema,
blessure: TeDeumBlessureSchema,
maladie: TeDeumMaladieSchema,
2023-12-11 22:24:19 +01:00
};
2024-02-19 22:02:44 +01:00
console.log("TeDeum RPG | Ready");
2023-12-11 20:11:10 +01:00
Actors.unregisterSheet("core", ActorSheet);
2024-02-19 22:02:44 +01:00
Actors.registerSheet("fvtt-te-deum", TeDeumActorPJSheet, { types: ["pj"], makeDefault: true });
Actors.registerSheet("fvtt-te-deum", TeDeumActorPJSheet, { types: ["pnj"], makeDefault: true });
2023-12-11 22:24:19 +01:00
2023-12-11 20:11:10 +01:00
Items.unregisterSheet("core", ItemSheet);
2024-02-29 22:35:12 +01:00
Items.registerSheet("fvtt-te-deum", TeDeumItemSheet, { makeDefault: true });
2023-12-11 20:11:10 +01:00
2024-02-19 22:02:44 +01:00
TeDeumUtility.init()
2023-12-11 20:11:10 +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
});
}
2024-02-19 22:02:44 +01:00
2024-02-29 22:35:12 +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-02-19 22:02:44 +01:00
TeDeumUtility.ready();
2023-12-11 20:11:10 +01:00
2025-02-03 23:00:59 +01:00
TeDeumUtility.importDefaultScene()
TeDeumUtility.welcomeMessage();
2024-02-29 22:35:12 +01:00
2023-12-11 20:11:10 +01:00
})
/* -------------------------------------------- */
/* Foundry VTT Initialization */
/* -------------------------------------------- */
Hooks.on("chatMessage", (html, content, msg) => {
if (content[0] == '/') {
let regExp = /(\S+)/g;
let commands = content.match(regExp);
2023-12-11 21:41:51 +01:00
if (game.system.tedeum.commands.processChatCommand(commands, content, msg)) {
2023-12-11 20:11:10 +01:00
return false;
}
}
return true;
});