diff --git a/module/actor-sheet.js b/module/actor-sheet.js index dd5add0a..73663473 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -2,13 +2,13 @@ * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ -export class SimpleActorSheet extends ActorSheet { +export class RdDActorSheet extends ActorSheet { /** @override */ static get defaultOptions() { return mergeObject(super.defaultOptions, { - classes: ["worldbuilding", "sheet", "actor"], - template: "systems/worldbuilding/templates/actor-sheet.html", + classes: ["rdd", "sheet", "actor"], + template: "systems/foundryvtt-reve-de-dragon/templates/actor-sheet.html", width: 600, height: 600, tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description"}], @@ -18,18 +18,6 @@ export class SimpleActorSheet extends ActorSheet { /* -------------------------------------------- */ - /** @override */ - getData() { - const data = super.getData(); - data.dtypes = ["String", "Number", "Boolean"]; - for ( let attr of Object.values(data.data.attributes) ) { - attr.isCheckbox = attr.dtype === "Boolean"; - } - return data; - } - - /* -------------------------------------------- */ - /** @override */ activateListeners(html) { super.activateListeners(html); @@ -51,8 +39,6 @@ export class SimpleActorSheet extends ActorSheet { li.slideUp(200, () => this.render(false)); }); - // Add or Remove Attribute - html.find(".attributes").on("click", ".attribute-control", this._onClickAttributeControl.bind(this)); } /* -------------------------------------------- */ @@ -66,64 +52,12 @@ export class SimpleActorSheet extends ActorSheet { return position; } - /* -------------------------------------------- */ - - /** - * Listen for click events on an attribute control to modify the composition of attributes in the sheet - * @param {MouseEvent} event The originating left click event - * @private - */ - async _onClickAttributeControl(event) { - event.preventDefault(); - const a = event.currentTarget; - const action = a.dataset.action; - const attrs = this.object.data.data.attributes; - const form = this.form; - - // Add new attribute - if ( action === "create" ) { - const nk = Object.keys(attrs).length + 1; - let newKey = document.createElement("div"); - newKey.innerHTML = ``; - newKey = newKey.children[0]; - form.appendChild(newKey); - await this._onSubmit(event); - } - - // Remove existing attribute - else if ( action === "delete" ) { - const li = a.closest(".attribute"); - li.parentElement.removeChild(li); - await this._onSubmit(event); - } - } /* -------------------------------------------- */ /** @override */ _updateObject(event, formData) { - // Handle the free-form attributes list - const formAttrs = expandObject(formData).data.attributes || {}; - const attributes = Object.values(formAttrs).reduce((obj, v) => { - let k = v["key"].trim(); - if ( /[\s\.]/.test(k) ) return ui.notifications.error("Attribute keys may not contain spaces or periods"); - delete v["key"]; - obj[k] = v; - return obj; - }, {}); - - // Remove attributes which are no longer used - for ( let k of Object.keys(this.object.data.data.attributes) ) { - if ( !attributes.hasOwnProperty(k) ) attributes[`-=${k}`] = null; - } - - // Re-combine formData - formData = Object.entries(formData).filter(e => !e[0].startsWith("data.attributes")).reduce((obj, e) => { - obj[e[0]] = e[1]; - return obj; - }, {_id: this.object._id, "data.attributes": attributes}); - // Update the Actor return this.object.update(formData); } diff --git a/module/actor.js b/module/actor.js index 0f85c7f2..b1d31c91 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2,12 +2,43 @@ * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * @extends {Actor} */ -export class SimpleActor extends Actor { +export class RdDActor extends Actor { + prepareData() { + super.prepareData(); + const actorData = this.data; + const data = actorData.data; + const flags = actorData.flags; + const comp = { "base": [], + "mêlée": [], + "tir": [], + "particulières": [], + "spécialisées": [], + "connaissances": [], + "draconic": [] + } + // Make separate methods for each Actor type (character, npc, etc.) to keep + // things organized. + if (actorData.type === 'personnage') this._prepareCharacterData(actorData); + } + + /** + * Prepare Character type specific data + */ + _prepareCharacterData(actorData) { + + for (let i of actorData.items) + { + if (i.type === "compétence") { + comp[i.catégorie].push( i ); + } + } + } + /** @override */ getRollData() { const data = super.getRollData(); - const shorthand = game.settings.get("worldbuilding", "macroShorthand"); + const shorthand = game.settings.get("foundryvtt-reve-de-dragon", "macroShorthand"); // Re-map all attributes onto the base roll data if ( !!shorthand ) { diff --git a/module/item-sheet.js b/module/item-sheet.js index 8d378e1e..6ab42b44 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -2,7 +2,7 @@ * Extend the basic ItemSheet with some very simple modifications * @extends {ItemSheet} */ -export class SimpleItemSheet extends ItemSheet { +export class RdDItemSheet extends ItemSheet { /** @override */ static get defaultOptions() { diff --git a/module/simple.js b/module/simple.js index a2337acb..5aeb8423 100644 --- a/module/simple.js +++ b/module/simple.js @@ -5,16 +5,16 @@ */ // Import Modules -import { SimpleActor } from "./actor.js"; -import { SimpleItemSheet } from "./item-sheet.js"; -import { SimpleActorSheet } from "./actor-sheet.js"; +import { RdDActor } from "./actor.js"; +import { RdDItemSheet } from "./item-sheet.js"; +import { RdDActorSheet } from "./actor-sheet.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ /* -------------------------------------------- */ Hooks.once("init", async function() { - console.log(`Initializing Simple Worldbuilding System`); + console.log(`Initializing Reve de Dragon System`); /** * Set an initiative formula for the system @@ -26,16 +26,16 @@ Hooks.once("init", async function() { }; // Define custom Entity classes - CONFIG.Actor.entityClass = SimpleActor; + CONFIG.Actor.entityClass = RdDActor; // Register sheet application classes Actors.unregisterSheet("core", ActorSheet); - Actors.registerSheet("dnd5e", SimpleActorSheet, { makeDefault: true }); + Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { makeDefault: true }); Items.unregisterSheet("core", ItemSheet); - Items.registerSheet("dnd5e", SimpleItemSheet, {makeDefault: true}); + Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true}); // Register system settings - game.settings.register("worldbuilding", "macroShorthand", { + game.settings.register("foundryvtt-reve-de-dragon", "macroShorthand", { name: "Shortened Macro Syntax", hint: "Enable a shortened macro syntax which allows referencing attributes directly, for example @str instead of @attributes.str.value. Disable this setting if you need the ability to reference the full attribute model, for example @attributes.str.label.", scope: "world", diff --git a/system.json b/system.json index a326b95a..5cd82bd9 100644 --- a/system.json +++ b/system.json @@ -2,10 +2,10 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "L'implémentation de Rêve de Dragon pour FoundryVTT", - "version": 0.1, + "version": 0.2, "minimumCoreVersion": "0.5.7", "compatibleCoreVersion": "0.5.7", - "templateVersion": 1, + "templateVersion": 3, "author": "LeRatierBretonnien", "esmodules": ["module/simple.js"], "styles": ["styles/simple.css"], diff --git a/template.json b/template.json index 48ce3018..3bef4b26 100644 --- a/template.json +++ b/template.json @@ -3,106 +3,173 @@ "types": ["personnage"], "templates": { "background": { - "biographie": "", + "biographie": "Histoire personnelle...", "yeux": "", "cheveux": "" - } }, - "carac": { - "taille": { - "value": 10, - "label": "Taille", - "xp": 0 + "common": { + "carac": { + "taille": { + "type": "number", + "value": 10, + "label": "Taille", + "xp": 0 + }, + "apparence": { + "type": "number", + "value": 10, + "label": "Apparence", + "xp": 0 + }, + "constitution": { + "type": "number", + "value": 10, + "label": "Constitution", + "xp": 0 + }, + "force": { + "type": "number", + "value": 10, + "label": "Force", + "xp": 0 + }, + "agilite": { + "type": "number", + "value": 10, + "label": "Agilité", + "xp": 0 + }, + "dexterite": { + "type": "number", + "value": 10, + "label": "Dexterité", + "xp": 0 + }, + "vue": { + "type": "number", + "value": 10, + "label": "Vue", + "xp": 0 + }, + "ouie": { + "type": "number", + "value": 10, + "label": "Ouïe", + "xp": 0 + }, + "odoratgout": { + "type": "number", + "value": 10, + "label": "Odorat-Goût", + "xp": 0 + }, + "volonte": { + "type": "number", + "value": 10, + "label": "Volonté", + "xp": 0 + }, + "intellect": { + "type": "number", + "value": 10, + "label": "Intellect", + "xp": 0 + }, + "empathie": { + "type": "number", + "value": 10, + "label": "Empathie", + "xp": 0 + }, + "reve": { + "type": "number", + "value": 10, + "label": "Rêve", + "xp": 0 + }, + "chance": { + "type": "number", + "value": 10, + "label": "Chance", + "xp": 0 + } }, - "apparence": { - "value": 10, - "label": "Apparence", - "xp": 0 - }, - "constitution": { - "value": 10, - "label": "Constitution", - "xp": 0 - }, - "force": { - "value": 10, - "label": "Force", - "xp": 0 - }, - "agilité": { - "value": 10, - "label": "Agilité", - "xp": 0 - }, - "dexterité": { - "value": 10, - "label": "Dexterité", - "xp": 0 - }, - "vue": { - "value": 10, - "label": "Vue", - "xp": 0 - }, - "ouïe": { - "value": 10, - "label": "Ouïe", - "xp": 0 - }, - "odoratgout": { - "value": 10, - "label": "Odorat-Goût", - "xp": 0 - }, - "volonté": { - "value": 10, - "label": "Volonté", - "xp": 0 - }, - "intellect": { - "value": 10, - "label": "Intellect", - "xp": 0 - }, - "empathie": { - "value": 10, - "label": "Empathie", - "xp": 0 - }, - "rêve": { - "value": 10, - "label": "Rêve", - "xp": 0 - }, - "chance": { - "value": 10, - "label": "Chance", - "xp": 0 - } - }, - "secondaires": { - "vie": { - "max": 10, - "current": 10, - "label": "Points de Vie" - }, - "fatigue": { - "max": 40, - "current": 10, - "label": "Points de Fatigue" + "sante": { + "vie": { + "type": "number", + "max": 10, + "value": 10, + "label": "Points de Vie" + }, + "endurance": { + "type": "number", + "max": 10, + "value": 10, + "label": "Points d'Endurance" + }, + "fatigue": { + "type": "number", + "max": 40, + "value": 10, + "label": "Points de Fatigue" + } } + } }, "personnage": { - "template": [ "background", "carac", "secondaires"] + "templates": [ "background", "common"] } }, "Item": { - "types": ["item"], - "item": { + "types": ["objet", "arme", "armure", "compétence", "sort", "herbe", "ingrédient", "livre", "potion"], + "objet": { "description": "", "quantité": 1, "poids": 0, "attributs": {} + }, + "arme": { + "description": "", + "quantité": 1, + "poids": 0, + "attributs": {} + }, + "armure": { + "description": "", + "quantité": 1, + "poids": 0, + "attributs": {} + }, + "compétence": { + "niveau": 0, + "base": 0, + "catégorie": "", + "xp": 0 + "description": "" + }, + "sort": { + "description": "", + "draconic": "", + "difficulté": 0, + "portée": 0 + }, + "herbe": { + "description": "", + "niveau": 0, + "base": 0 + }, + "ingredient": { + "description": "", + "niveau": 0, + "base": 0 + }, + "livre": { + "description": "", + "difficulté": 0, + "taches": 0 + }, + "potion": { + "description": "" } } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index c51e2a3b..d8628d25 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -6,20 +6,22 @@

- + / - +
- + / - +
{{!-- Sheet Tab Navigation --}}