diff --git a/RdD.geany b/RdD.geany index 81ed1857..28377e84 100644 --- a/RdD.geany +++ b/RdD.geany @@ -20,13 +20,29 @@ indent_mode=2 [project] name=RdD base_path=/home/sigmar/work/foundryvtt/foundryvtt-reve-de-dragon +description= [long line marker] long_line_behaviour=1 long_line_column=72 [files] -current_page=0 +current_page=6 +FILE_NAME_0=4198;JSON;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplate.json;0;2 +FILE_NAME_1=3416;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Ftemplates%2Factor-sheet.html;0;2 +FILE_NAME_2=241;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Fsimple.js;0;2 +FILE_NAME_3=1321;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor-sheet.js;0;2 +FILE_NAME_4=946;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Factor.js;0;2 +FILE_NAME_5=127;TypeScript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Fmodule%2Fitem-sheet.ts;0;2 +FILE_NAME_6=6346;TypeScript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Fmodule%2Fcharacter-sheet.ts;0;2 +FILE_NAME_7=4589;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Ftemplates%2Factors%2Fcharacter-sheet.html;0;2 +FILE_NAME_8=0;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Ftemplates%2Factors%2Fpartials%2Fedges-tab.html;0;2 +FILE_NAME_9=0;HTML;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Ftemplates%2Factors%2Fpartials%2Fsummary-tab.html;0;2 +FILE_NAME_10=77;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Ffoundryvtt-reve-de-dragon%2Fmodule%2Frdd-utility.js;0;2 +FILE_NAME_11=3385;TypeScript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2Fswade%2Fsrc%2Fmodule%2Fentity.ts;0;2 +FILE_NAME_12=427;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Futility-wfrp4e.js;0;2 +FILE_NAME_13=42276;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Factor%2Factor-wfrp4e.js;0;2 +FILE_NAME_14=4223;Javascript;0;EUTF-8;0;1;0;%2Fhome%2Fsigmar%2Fwork%2Ffoundryvtt%2FWFRP-4th-Edition-FoundryVTT_SLADECRAVEN%2Fscripts%2Fdice-wfrp4e.js;0;2 [VTE] last_dir=/home/sigmar diff --git a/module/actor-sheet.js b/module/actor-sheet.js index a400baa9..a129a022 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -2,6 +2,9 @@ * Extend the basic ActorSheet with some very simple modifications * @extends {ActorSheet} */ + +import { RdDUtility } from "./rdd-utility.js"; + export class RdDActorSheet extends ActorSheet { /** @override */ @@ -16,6 +19,15 @@ export class RdDActorSheet extends ActorSheet { }); } + /* -------------------------------------------- */ + + _checkNull(items) { + if (items && items.length) { + return items; + } + return []; + } + /* -------------------------------------------- */ getData() { @@ -33,7 +45,7 @@ export class RdDActorSheet extends ActorSheet { data.competenceByCategory = {}; if (data.itemsByType.competence) { for (const item of data.itemsByType.competence) { - console.log("Push...", item, item.data.categorie); + //console.log("Push...", item, item.data.categorie); let list = data.competenceByCategory[item.data.categorie]; if (!list) { list = []; @@ -76,6 +88,12 @@ export class RdDActorSheet extends ActorSheet { li.slideUp(200, () => this.render(false)); }); + // Roll Skill + html.find('.competence-label a').click((event) => { + let compName = event.currentTarget.text; + this.actor.rollCompetence( compName); + }); + } /* -------------------------------------------- */ diff --git a/module/actor.js b/module/actor.js index 2428398d..a5b331d9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2,7 +2,13 @@ * Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system. * @extends {Actor} */ + +import { RdDUtility } from "./rdd-utility.js"; + export class RdDActor extends Actor { + + /* -------------------------------------------- */ + prepareData() { super.prepareData(); @@ -21,6 +27,33 @@ export class RdDActor extends Actor { _prepareCharacterData(actorData) { } + + /* -------------------------------------------- */ + + rollCompetence( compName ) { + + let compItem = RdDUtility.findCompetence( this.data.items, compName); + console.log("Roll !", compItem ); + renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', compItem).then(dlg => + { + new Dialog( + { + title: "Test de compétence", + content: dlg, + buttons: + { + rollButton: + { + label: "Lancer" + //callback: html => dialogOptions.callback(html, roll) + } + }, + default: "rollButton" + }).render(true); + }); + } + + /* -------------------------------------------- */ /** @override */ getRollData() { diff --git a/module/rdd-utility.js b/module/rdd-utility.js new file mode 100644 index 00000000..86157dfe --- /dev/null +++ b/module/rdd-utility.js @@ -0,0 +1,17 @@ +/* Common useful functions shared between objects */ + +export class RdDUtility { + + static findCompetence(compList, compName) + { + for (const item of compList) { + if (item.name == compName) { + console.log("Found item !", item); + return item; + } + } + } + + +} + diff --git a/module/simple.js b/module/simple.js index e7712714..390196c3 100644 --- a/module/simple.js +++ b/module/simple.js @@ -22,7 +22,7 @@ RDD.level_category = { import { RdDActor } from "./actor.js"; import { RdDItemSheet } from "./item-sheet.js"; import { RdDActorSheet } from "./actor-sheet.js"; - +import { RdDUtility } from "./rdd-utility.js"; /* -------------------------------------------- */ // Handlers management @@ -34,7 +34,9 @@ const preloadHandlebarsTemplates = async function () { 'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-categorie.html', 'systems/foundryvtt-reve-de-dragon/templates/competence-carac-defaut.html', - 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html' + 'systems/foundryvtt-reve-de-dragon/templates/competence-base.html', + // Dialogs + 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' ]; return loadTemplates(templatePaths); @@ -68,13 +70,4 @@ Hooks.once("init", async function() { Items.unregisterSheet("core", ItemSheet); Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, {makeDefault: true}); - // Register system settings - 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", - type: Boolean, - default: true, - config: true - }); }); diff --git a/system.json b/system.json index 4506b076..8c370e57 100644 --- a/system.json +++ b/system.json @@ -5,7 +5,7 @@ "version": 0.2, "minimumCoreVersion": "0.5.7", "compatibleCoreVersion": "0.5.7", - "templateVersion": 4, + "templateVersion": 5, "author": "LeRatierBretonnien", "esmodules": ["module/simple.js"], "styles": ["styles/simple.css"], diff --git a/template.json b/template.json index 013329a3..aaaec835 100644 --- a/template.json +++ b/template.json @@ -126,27 +126,31 @@ "description": "", "quantite": 1, "encombrement": 0, - "equipe": false + "equipe": false, + "cout": 0 }, "arme": { "description": "", "quantite": 1, "encombrement": 0, "equipe": false, - "dommages": 0 + "dommages": 0, + "cout": 0 }, "munition": { "description": "", "quantite": 1, "encombrement": 0, - "equipe": false + "equipe": false, + "cout": 0 }, "armure": { "description": "", "quantite": 1, "encombrement": 0, "equipe": false, - "pa": 0 + "pa": 0, + "cout": 0 }, "competence": { "niveau": 0, @@ -165,23 +169,29 @@ "herbe": { "description": "", "niveau": 0, - "base": 0 + "base": 0, + "cout": 0 }, "ingredient": { "description": "", "niveau": 0, "encombrement": 0, - "base": 0 + "base": 0, + "cout": 0 }, "livre": { "description": "", + "auteur": "", "difficulte": 0, - "taches": 0, - "encombrement": 0 + "points_de_tache": 0, + "points_de_tache_courant": 0, + "encombrement": 0, + "cout": 0 }, "potion": { "description": "", - "encombrement": 0 + "encombrement": 0, + "cout": 0 } } } diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 2c5eae6a..b7a47e2d 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -33,16 +33,16 @@ {{!-- Carac Tab --}}