diff --git a/module/actor.js b/module/actor.js new file mode 100644 index 0000000..927ed37 --- /dev/null +++ b/module/actor.js @@ -0,0 +1,54 @@ +import { SoSUtility } from "./sos-utility.js"; + + +/* -------------------------------------------- */ +/** + * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. + * @extends {Actor} + */ +export class SoSActor extends Actor { + + /* -------------------------------------------- */ + /** + * Override the create() function to provide additional SoS functionality. + * + * This overrided create() function adds initial items + * Namely: Basic skills, money, + * + * @param {Object} data Barebones actor data which this function adds onto. + * @param {Object} options (Unused) Additional options which customize the creation workflow. + * + */ + + static async create(data, options) { + + // Case of compendium global import + if (data instanceof Array) { + return super.create(data, options); + } + // If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic + if (data.items) { + let actor = super.create(data, options); + return actor; + } + + + return super.create(data, options); + } + + /* -------------------------------------------- */ + prepareData() { + super.prepareData(); + + const actorData = this.data; + } + + /* -------------------------------------------- */ + /** + * Prepare Character type specific data + */ + async _prepareCharacterData(actorData) { + // Initialize empty items + } + +} diff --git a/module/sos-main.js b/module/sos-main.js new file mode 100644 index 0000000..2d3f638 --- /dev/null +++ b/module/sos-main.js @@ -0,0 +1,117 @@ +/** + * RdD system + * Author: LeRatierBretonnien + * Software License: GNU GPLv3 + */ + +/* -------------------------------------------- */ + +/* -------------------------------------------- */ +// Import Modules +import { SoSActor } from "./actor.js"; +import { SoSItemSheet } from "./item-sheet.js"; +import { SoSActorSheet } from "./actor-sheet.js"; +import { SoSUtility } from "./rdd-utility.js"; +import { SoSTokenHud } from "./rdd-token-hud.js"; +import { SoSCommands } from "./rdd-commands.js"; + +/* -------------------------------------------- */ +/* Foundry VTT Initialization */ +/* -------------------------------------------- */ + +/************************************************************************************/ +const _patch_initiative = () => { + Combat.prototype.rollInitiative = async function ( + ids, + formula = undefined, + messageOptions = {} + ) { + } +} + +/************************************************************************************/ +Hooks.once("init", async function () { + console.log(`Initializing Shadows over Sol System`); + + // preload handlebars templates + SoSUtility.preloadHandlebarsTemplates(); + // Create useful storage space + game.system.sos = { TMRUtility: TMRUtility } + + /* -------------------------------------------- */ + // Set an initiative formula for the system + CONFIG.Combat.initiative = { + formula: "1+(1d6/10)", + decimals: 2 + }; + + /* -------------------------------------------- */ + game.socket.on("system.foundryvtt-shadows-over-sol", data => { + SoSUtility.onSocketMesssage(data); + }); + + /* -------------------------------------------- */ + // Define custom Entity classes + CONFIG.Actor.entityClass = SoSActor; + CONFIG.SoS = { + } + + /* -------------------------------------------- */ + // Register sheet application classes + Actors.unregisterSheet("core", ActorSheet); + Actors.registerSheet("foundryvtt-reve-de-dragon", SoSActorSheet, { types: ["character"], makeDefault: true }); + Items.unregisterSheet("core", ItemSheet); + Items.registerSheet("foundryvtt-reve-de-dragon", SoSItemSheet, { makeDefault: true }); + + // Patch the initiative formula + _patch_initiative(); + +}); + +/* -------------------------------------------- */ +function welcomeMessage() { + ChatUtility.removeMyChatMessageContaining('
'); + ChatMessage.create({ + user: game.user._id, + whisper: [game.user._id], + content: `
Welcome !
+ ` }); +} + +/* -------------------------------------------- */ +/* Foundry VTT Initialization */ +/* -------------------------------------------- */ +Hooks.once("ready", function () { + + // User warning + if (!game.user.isGM && game.user.character == undefined) { + ui.notifications.info("Warning ! You are not linked to any actor !"); + ChatMessage.create({ + content: "WARNING Player " + game.user.name + " is not linked to an actor !", + user: game.user._id + }); + } + + welcomeMessage(); + +}); + +/* -------------------------------------------- */ +/* Foundry VTT Initialization */ +/* -------------------------------------------- */ +Hooks.on("chatMessage", (html, content, msg) => { + if (content[0] == '/') { + let regExp = /(\S+)/g; + let commands = content.toLowerCase().match(regExp); + if (game.system.sos.commands.processChatCommand(commands, content, msg)) { + return false; + } + } + return true; +}); + +/* -------------------------------------------- */ +Hooks.on("getCombatTrackerEntryContext", (html, options) => { + RdDUtility.pushInitiativeOptions(html, options); +} +) diff --git a/module/sos-utility.js b/module/sos-utility.js new file mode 100644 index 0000000..362631a --- /dev/null +++ b/module/sos-utility.js @@ -0,0 +1,9 @@ + +export class SoSUtility { + /* -------------------------------------------- */ + static async preloadHandlebarsTemplates() { + const templatePaths = [ + ] + } + +} \ No newline at end of file diff --git a/template.json b/template.json index e451bee..915370f 100644 --- a/template.json +++ b/template.json @@ -14,9 +14,9 @@ } }, "background": { - "history": "Histoire personnelle...", + "history": "", "notes": "Notes", - "gmnotes": "Notes du MJ", + "gmnotes": "GM notes", "eyes": "", "hair": "", "weight": "",