From f1d7cfa1f888d43bedd063d91656378e025ff041 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Mon, 31 Oct 2022 15:19:08 +0100 Subject: [PATCH 1/7] =?UTF-8?q?T=C3=A2ches=20sans=20comp=C3=A9tences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/item-competence.js | 31 ++++++++++++++++++++++++------- template.json | 4 ++-- templates/item-tache-sheet.html | 1 + 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/module/item-competence.js b/module/item-competence.js index c2cdcb78..f61d1310 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -85,9 +85,9 @@ export class RdDItemCompetence extends Item { /* -------------------------------------------- */ static getVoieDraconic(competences, voie) { return RdDItemCompetence.findFirstItem(competences, voie, { - preFilter: it => it.isCompetence() && RdDItemCompetence.isDraconic(it), - description: 'Draconic', - }); + preFilter: it => it.isCompetence() && RdDItemCompetence.isDraconic(it), + description: 'Draconic', + }); } /* -------------------------------------------- */ @@ -199,7 +199,7 @@ export class RdDItemCompetence extends Item { item.system.isStressLevelUp = (xpManquant > 0 && stressTransforme >= xpManquant && item.system.niveau < item.system.niveau_archetype); item.system.stressXpMax = 0; if (xpManquant > 0 && stressTransforme > 0 && item.system.niveau < item.system.niveau_archetype) { - item.system.stressXpMax = Math.min(xpManquant , stressTransforme); + item.system.stressXpMax = Math.min(xpManquant, stressTransforme); } } @@ -219,10 +219,10 @@ export class RdDItemCompetence extends Item { /* -------------------------------------------- */ static findCompetence(list, idOrName, options = {}) { - if (idOrName == undefined) { - return undefined; + if (idOrName == undefined || idOrName == "") { + return RdDItemCompetence.sansCompetence(); } - options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, {overwrite: false}); + options = mergeObject(options, { preFilter: it => it.isCompetence(), description: 'compétence' }, { overwrite: false }); return RdDItemCompetence.findFirstItem(list, idOrName, options); } @@ -231,6 +231,23 @@ export class RdDItemCompetence extends Item { return Misc.findAllLike(name, list, { filter: it => it.isCompetence(), description: 'compétence' }); } + static sansCompetence() { + return { + name: "Sans compétence", + type: "competence", + img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.webp", + system: { + niveau: 0, + default_diffLibre: 0, + base: 0, + categorie: "Aucune", + description: "", + descriptionmj: "", + defaut_carac: "", + } + }; + } + static findFirstItem(list, idOrName, options) { return list.find(it => it.id == idOrName && options.preFilter(it)) ?? Misc.findFirstLike(idOrName, list, options); diff --git a/template.json b/template.json index 2f567bc6..d25dfcbd 100644 --- a/template.json +++ b/template.json @@ -746,9 +746,9 @@ "carac": "", "competence": "", "periodicite": "", - "fatigue": 0, + "fatigue": 1, "difficulte": 0, - "points_de_tache": 0, + "points_de_tache": 4, "points_de_tache_courant": 0, "nb_jet_echec": 0, "nb_jet_succes": 0, diff --git a/templates/item-tache-sheet.html b/templates/item-tache-sheet.html index cd64c489..880b7676 100644 --- a/templates/item-tache-sheet.html +++ b/templates/item-tache-sheet.html @@ -16,6 +16,7 @@ {{#select system.competence}} - {{#each competences as |competence key|}} + {{#each (trier competences) as |competence key|}} {{/each}} {{/select}} diff --git a/templates/item-meditation-sheet.html b/templates/item-meditation-sheet.html index 21db9a13..77aa8bb2 100644 --- a/templates/item-meditation-sheet.html +++ b/templates/item-meditation-sheet.html @@ -6,7 +6,7 @@ {{#select system.competence}} - {{#each competences as |competence key|}} + {{#each (trier competences) as |competence key|}} {{/each}} {{/select}} diff --git a/templates/item-tache-sheet.html b/templates/item-tache-sheet.html index 880b7676..b0d4f532 100644 --- a/templates/item-tache-sheet.html +++ b/templates/item-tache-sheet.html @@ -17,7 +17,7 @@ - - Vous devez acquérir {{carac.xpNext}} points d'Experience pour augmenter de 1 votre {{carac.label}} + + Vous devez acquérir {{carac.xpNext}} points d'Experience pour augmenter de 1 votre {{carac.label}} {{#if carac.isLevelUp}} diff --git a/templates/actor/competence.html b/templates/actor/competence.html index 85e6ab21..d9de370a 100644 --- a/templates/actor/competence.html +++ b/templates/actor/competence.html @@ -6,7 +6,7 @@ {{#if system.isLevelUp}} - Vous pouvez dépenser {{system.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{name}} + Vous pouvez dépenser {{system.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{name}} @@ -17,10 +17,12 @@ {{#unless @root.options.vueDetaillee}}disabled{{/unless}} /> {{#if @root.options.vueDetaillee}} - + + {{#unless system.isLevelUp}} Vous devez acquérir {{system.xpNext}} points d'Experience pour augmenter de 1 votre compétence {{name}} + {{/unless}} {{/if}} {{#if (eq system.categorie 'draconic')}}